Hi all, I can’t figure out why this isn’t spinning. Any tips? (It works in Processing).
var spin;
function setup() {
createCanvas(400, 400);
background(255);
}
function draw() {
}
function mouseDragged() {
push();
translate(mouseX-20, mouseY);
rotate(spin);
ellipse(0, 0, 80, 20);
pop();
push();
translate(mouseX+20, mouseY);
rotate(spin);
ellipse(0, 0, 80, 20);
pop();
spin+=0.1;
}
function keyPressed() {
background(255);
}
Here’s the Processing sketch:
float spin;
void setup() {
size(400, 400);
background(255);
}
void draw() {
}
void mouseDragged() {
pushMatrix();
translate(mouseX-20, mouseY);
rotate(spin);
ellipse(0, 0, 80, 20);
popMatrix();
pushMatrix();
translate(mouseX+20, mouseY);
rotate(spin);
ellipse(0, 0, 80, 20);
popMatrix();
spin+=0.1;
}
void keyPressed() {
background(255);
}