Skip to content

Instantly share code, notes, and snippets.

@kuzemkon
Last active August 29, 2015 14:09
Show Gist options
  • Save kuzemkon/ef8e5c4edc7b101a725f to your computer and use it in GitHub Desktop.
Save kuzemkon/ef8e5c4edc7b101a725f to your computer and use it in GitHub Desktop.
FlowLip[] lips = new FlowLip[5];
void setup() {
size(1000,1000);
for (int i=0; i< lips.length; i++) {
float x=random(width-500);
float y=random(height-500);
float a=random(255);
float z=random(600);
float q=random(600);
if (i%2==0) {
lips[i]=new FlowLip(color(a,120-a,20+a),x,y);
}
if (i%2 != 0) {
lips[i]=new FlowLip(color(200,0,0),z,q);
}
}
}
void draw() {
background(228);
for (int i=0; i< lips.length; i++) {
lips[i].move();
lips[i].display();
lips[i].change();
lips[i].cull();
}
}
class FlowLip {
color c;
float a;
float b;
float z;
float q;
float speed = 2.5;
FlowLip(color tempC,float tempA,float tempB) {
c=tempC;
a=tempA;
b=tempB;
}
void cull () {
z=40*cos(.1*z);
q=20*sin(.1*q);
}
void change () {
a=random(600);
}
void move() {
a+=random(-speed,speed);
b+=random(-speed,speed);
}
void display() {
pushMatrix();
translate(a,b);
pushMatrix();
translate(150,230);
stroke(0,100,0);
noFill();
gip();
popMatrix();
pushMatrix();
translate(420, 205);
for(int i=0; i<8; i++) {
rotate(PI/4);
fill(c);
stroke(200, 0, 0);
petal();
}
fill(217, 245, 129);
stroke(217, 245, 129);
ellipse(0, 0, 50, 50);
popMatrix();
pushMatrix();
translate(100,200);
rotate(-PI/9);
stroke(0,100,0);
fill(0,150,0);
lystok();
popMatrix();
pushMatrix();
translate(100,200);
stroke(0,100,0);
noFill();
steblo();
popMatrix();
pushMatrix();
translate(150,350);
rotate(-PI/7);
stroke(0,100,0);
noFill();
zalupky();
popMatrix();
pushMatrix();
translate(160,390);
rotate(-PI/8);
stroke(0,100,0);
noFill();
zalupky();
popMatrix();
pushMatrix();
translate(135,300);
rotate(-PI/6);
stroke(0,100,0);
noFill();
kentavr();
popMatrix();
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 zalupky() {
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