bezier tiling
@author
int cellNum = 160;
float cellSize = 40;
void setup(){
size(640, 640);
mousePressed();
}
void mousePressed(){
background(255);
stroke(random(255), random(255), random(255));
strokeWeight(1);
color c1 = color(random(255), random(255), random(255));
color c2 = color(random(255), random(255), random(255));
PVector cpx1 = new PVector(random(0, cellSize / 2), random(-cellSize / 2, cellSize / 2));
PVector cpx2 = new PVector(random(cellSize / 2, cellSize), random(-cellSize / 2, cellSize / 2));
PVector cpy1 = new PVector(random(-cellSize / 2, cellSize / 2), random(0, cellSize / 2));
PVector cpy2 = new PVector(random(-cellSize / 2, cellSize / 2), random(cellSize / 2, cellSize));
for(int x = -1; x < cellNum + 1; x++){
for(int y = -1; y < cellNum + 1; y++){
float w = x * cellSize;
float h = y * cellSize;
if((x + y) % 2 == 0){
fill(c1);
} else {
fill(c2);
}
pushMatrix();
translate(w, h);
beginShape();
vertex(0, 0);
bezierVertex(cpx1.x, cpx1.y, cpx2.x, cpx2.y, cellSize, 0);
bezierVertex(cellSize + cpy1.x, cpy1.y, cellSize + cpy2.x, cpy2.y, cellSize, cellSize);
bezierVertex(cpx2.x, cellSize + cpx2.y, cpx1.x, cellSize + cpx1.y, 0, cellSize);
bezierVertex(cpy2.x, cpy2.y, cpy1.x, cpy1.y, 0, 0);
endShape();
popMatrix();
}
}
}
void draw(){
}