/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.IxnOnNXug-D/rev.1791
*
* authors:
* frederic.vernier
*
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
float a = 0;
void setup() {
size(700, 700);
smooth();
strokeWeight(2);
noLoop();
}
void drawPoly(int x, int y, R, int v){
float ANG = PI/3;
colorMode(HSB);
// dessine une courbe point par point
stroke(v, 255, 128);
for (int k=1; k<5; k++){
strokeWeight(5-k);
fill (v, 128, 255-k*32);
beginShape();
vertex(x+R*cos(0), y+R*sin(0));
for (int i=0; i<6; i++) {
int x0 = x+R*cos(i*ANG);
int y0 = y+R*sin(i*ANG);
int x1 = x+R*cos((i+1)*ANG);
int y1 = y+R*sin((i+1)*ANG);
int dx = (y0-y1)/(2*k)*(1+cos(a));
int dy = (x1-x0)/(2*k)*(1+cos(a));
if (i%2==0)
bezierVertex(1*(x0+x1)/2-dx, 1*(y0+y1)/2-dy,
1*(x0+x1)/2-dx, 1*(y0+y1)/2-dy, x1, y1);
else
bezierVertex(1*(x0+x1)/2+dx, 1*(y0+y1)/2+dy,
1*(x0+x1)/2+dx, 1*(y0+y1)/2+dy, x1, y1);
}
endShape(CLOSE);
R=R/2;
}
}
void draw() {
a= (a-PI/32)%TWO_PI;
int R = 50
background(255);
for(int j=0; j<height/R/2+1; j++) {
translate(0, R);
pushMatrix();
for (int i=0; i<width/R/2+2; i++) {
if (i%2==0) translate(0, -R);
int v = random(0, 255);
v= (i%2+3-j%3)%3*75;
drawPoly(0, 0, R, v);
if (i%2==0) translate(0, R);
translate(R*sqrt(3), 0);
}
popMatrix();
translate(0, R);
}
}
void mouseOver(){
loop();
}
void mouseOut(){
noLoop();
}