xxxxxxxxxx
18
let angle = 0;
function setup() {
createCanvas(400, 400);
angleMode(DEGREES);
}
function draw() {
background(0);
translate (200,200); //translate moves the position of the objects.
stroke (255);
line (0,0,50,50);
rotate(angle); //because i added "rotate" after the line, only the rectangle rotates, while the line doesn't move.
fill(255);
rect(0,0,100,50);
angle=angle+1 //this function makes the rectangle rotate.
}