Last active
August 29, 2015 14:07
-
-
Save kuzemkon/bdb7a5d36c5635c3c984 to your computer and use it in GitHub Desktop.
Interactivity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float a; | |
float b; | |
float[] x = new float[10]; | |
float[] y = new float[10]; | |
float r=50; | |
void setup() | |
{ | |
size(600,600); | |
background(255); | |
} | |
void draw() | |
{ | |
stroke(0,190,0); | |
if (keyPressed) { | |
if ((key=='m') || (key=='M')) { | |
noFill(); | |
stroke(0); | |
background(255); | |
x[0]=mouseX; | |
y[0]=mouseY; | |
for (int i=1; i<6; i++) { | |
x[i]=x[i-1]+r*cos(i*(PI/3)); | |
y[i]=y[i-1]+r*sin(i*(PI/3)); | |
} | |
beginShape(); | |
for (int i=0; i<6; i++) { | |
vertex(x[i],y[i]); | |
} | |
endShape(CLOSE); | |
for (int i=0; i<3; i++) { | |
line(x[i],y[i],x[i+3],y[i+3]); | |
} | |
} | |
} | |
if (b==0) {b=-1200;} | |
if (keyPressed) { | |
if ((key=='g') || (key=='G')) { | |
background(255); | |
noStroke(); | |
fill(59,11,219); | |
b++; | |
for (int i=-1200; i<1200; i+=100) { | |
for (int a=-1150; a<1200; a+=100) { | |
rect(i+b,a,50,50); | |
rect(a+b,i,50,50); | |
} | |
} | |
} | |
} | |
if (keyPressed == true) { | |
if (mousePressed && (mouseButton == LEFT)) { | |
line(mouseX,mouseY,pmouseX,pmouseY); | |
} | |
} | |
else if (keyPressed == false) { | |
if (mousePressed && (mouseButton == LEFT)) { | |
pushMatrix(); | |
translate(mouseX,mouseY); | |
stroke(0,100,0); | |
noFill(); | |
gip(); | |
popMatrix(); | |
pushMatrix(); | |
translate(mouseX+270, mouseY-25); | |
for(int i=0; i<8; i++) { | |
rotate(PI/4); | |
fill(200, 0, 0); | |
stroke(200, 0, 0); | |
petal(); | |
} | |
fill(217, 245, 129); | |
stroke(217, 245, 129); | |
ellipse(0, 0, 50, 50); | |
popMatrix(); | |
pushMatrix(); | |
translate(mouseX-50,mouseY-30); | |
rotate(-PI/9); | |
stroke(0,100,0); | |
fill(0,150,0); | |
lystok(); | |
popMatrix(); | |
pushMatrix(); | |
translate(mouseX-50,mouseY-30); | |
stroke(0,100,0); | |
noFill(); | |
steblo(); | |
popMatrix(); | |
pushMatrix(); | |
translate(mouseX,mouseY+120); | |
rotate(-PI/7); | |
stroke(0,100,0); | |
noFill(); | |
top(); | |
popMatrix(); | |
pushMatrix(); | |
translate(mouseX+10,mouseY+160); | |
rotate(-PI/8); | |
stroke(0,100,0); | |
noFill(); | |
top(); | |
popMatrix(); | |
pushMatrix(); | |
translate(mouseX-15,mouseY+70); | |
rotate(-PI/6); | |
stroke(0,100,0); | |
noFill(); | |
kentavr(); | |
popMatrix(); | |
} | |
if (mousePressed && (mouseButton == RIGHT)) { | |
if (a==450) { a=0; } | |
a++; | |
background(255); | |
pushMatrix(); | |
translate(a+mouseX,mouseY); | |
stroke(0,100,0); | |
noFill(); | |
gip(); | |
popMatrix(); | |
pushMatrix(); | |
translate(mouseX+270, mouseY-25-a); | |
for(int i=0; i<8; i++) { | |
rotate(PI/4); | |
fill(200, 0, 0); | |
stroke(200, 0, 0); | |
petal(); | |
} | |
fill(217, 245, 129); | |
stroke(217, 245, 129); | |
ellipse(0, 0, 50, 50); | |
popMatrix(); | |
pushMatrix(); | |
translate(mouseX-50,a+mouseY-30); | |
rotate(-PI/9); | |
stroke(0,100,0); | |
fill(0,150,0); | |
lystok(); | |
popMatrix(); | |
pushMatrix(); | |
translate(mouseX-50-a,mouseY-30); | |
stroke(0,100,0); | |
noFill(); | |
steblo(); | |
popMatrix(); | |
pushMatrix(); | |
translate(mouseX-a,mouseY+120); | |
rotate(-PI/7); | |
stroke(0,100,0); | |
noFill(); | |
top(); | |
popMatrix(); | |
pushMatrix(); | |
translate(mouseX+10-a,mouseY+160); | |
rotate(-PI/8); | |
stroke(0,100,0); | |
noFill(); | |
top(); | |
popMatrix(); | |
pushMatrix(); | |
translate(mouseX-15-a,mouseY+70); | |
rotate(-PI/6); | |
stroke(0,100,0); | |
noFill(); | |
kentavr(); | |
popMatrix(); | |
} | |
} | |
} | |
void petal() { | |
beginShape(); | |
curveVertex(0, 0); | |
curveVertex(0, 0); | |
curveVertex(100, 32); | |
curveVertex(150, 0); | |
curveVertex(100, -32); | |
curveVertex(0, 0); | |
curveVertex(0, 0); | |
endShape(); | |
} | |
void steblo() | |
{ | |
beginShape(); | |
curveVertex(0,0); | |
curveVertex(0,0); | |
curveVertex(50,100); | |
curveVertex(100,300); | |
curveVertex(120,350); | |
curveVertex(140,400); | |
endShape(); | |
} | |
void lystok() { | |
beginShape(); | |
curveVertex(0,0); | |
curveVertex(0,0); | |
curveVertex(50,175); | |
curveVertex(0,250); | |
curveVertex(-50,175); | |
curveVertex(0,0); | |
curveVertex(0,0); | |
endShape(); | |
} | |
void top() { | |
beginShape(); | |
curveVertex(50,0); | |
curveVertex(50,0); | |
curveVertex(25,25); | |
curveVertex(0,20); | |
curveVertex(-25,-25); | |
curveVertex(-50,0); | |
endShape(); | |
} | |
void kentavr() { | |
beginShape(); | |
curveVertex(35,0); | |
curveVertex(35,0); | |
curveVertex(25,25); | |
curveVertex(0,20); | |
curveVertex(-25,-25); | |
curveVertex(-35,0); | |
endShape(); | |
} | |
void gip() { | |
beginShape(); | |
curveVertex(0,200); | |
curveVertex(25,150); | |
curveVertex(75,75); | |
curveVertex(150,25); | |
curveVertex(200,5); | |
curveVertex(300,-20); | |
endShape(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment