// Using SetPivot()
BSpace s1; BImage img1; float angle;
void setup(){
size(200,200);
background(200);
smooth();
img1 = loadImage("arch.jpg");
s1 = new BSpace(this);
}
void loop(){
angle += 0.04;
// Set the pivot point for rotating/scaling the BSpace.
// In result, the image will always rotate arround the mouse cursor.
s1.setPivot(mouseX ,mouseY,0);
s1.rotateZ(angle);
s1.image(img1,0,0);
// cosmetic: draw the rotation pivot point -- the mouse cursor.
stroke(255,0,0);
line(mouseX-5, mouseY , mouseX+5, mouseY);
line(mouseX, mouseY - 5, mouseX, mouseY + 5);
stroke(0);
}
|