int angle = 0;
float a = 0.0;
float s = 0.0;
void setup() {
size(600, 800);
background(255);
}
void draw() {
if (mousePressed) {
a = a + mouseX;
s = cos(a)*2;
translate(width/2, height/2);
fill(0);
rect(0, 0, 50, 50);
translate(100, 50);
fill(#D39ED1);
scale(s);
rect(mouseX, mouseY, 50, 50);
} else
{
angle += 5;
float val = cos(radians(angle))*60;
for (int a = 0; a < 20; a +=50 ) {
float yoff = cos(radians(a)) * val;
float xoff = sin(radians(a)) * val;
fill(255);
ellipse(mouseX + yoff, mouseY + xoff, val, val);
}
fill(0);
rotate(angle);
line(mouseX, mouseY, angle*50, angle*10);
ellipse(mouseX, mouseY, 10, 10);
}
}
Link to Sketch in OpenProcessing:
https://www.openprocessing.org/sketch/383094
float a = 0.0;
float s = 0.0;
void setup() {
size(600, 800);
background(255);
}
void draw() {
if (mousePressed) {
a = a + mouseX;
s = cos(a)*2;
translate(width/2, height/2);
fill(0);
rect(0, 0, 50, 50);
translate(100, 50);
fill(#D39ED1);
scale(s);
rect(mouseX, mouseY, 50, 50);
} else
{
angle += 5;
float val = cos(radians(angle))*60;
for (int a = 0; a < 20; a +=50 ) {
float yoff = cos(radians(a)) * val;
float xoff = sin(radians(a)) * val;
fill(255);
ellipse(mouseX + yoff, mouseY + xoff, val, val);
}
fill(0);
rotate(angle);
line(mouseX, mouseY, angle*50, angle*10);
ellipse(mouseX, mouseY, 10, 10);
}
}
Link to Sketch in OpenProcessing:
https://www.openprocessing.org/sketch/383094
0 comments:
Post a Comment