Jigsaw-Puzzle-Piece generator
I made a processing sketch that generates a jigsaw-puzzle-piece using curveVertices
click here to run it or download the source
See also:
sketch experiment 7 - osc events
nested cubes in processing
processing phaseflower
Time Perception
de jong attractor
nested cubes in processing
processing phaseflower
Time Perception
de jong attractor
thanks!
I needed a bigger piece, so i modified your script a little:
/ a jigsaw puzzle piece by guru
click on the piece to generate a new one / int baseSize = 600; void setup() { size( floor(baseSize1.5), floor(baseSize1.5), P2D ); smooth(); } int halfBase = floor(baseSize/2); int threeQuartersBase = floor(baseSize0.75);
float f = ceil(baseSize/28);
float a = 1; float b = 1; float c = -1; float d = -1;
void draw() { background(255); strokeWeight(2); noFill();
beginShape(); vertex( baseSize, halfBase ); //right curveVertex( baseSize, halfBase ); curveVertex( baseSize,threeQuartersBase - 2 * f ); curveVertex( baseSize + f * a , threeQuartersBase - f ); curveVertex( baseSize + 2 * f * a, threeQuartersBase - f ); curveVertex( baseSize + 3 * f * a, threeQuartersBase - 2 * f ); curveVertex( baseSize + 4 * f * a, threeQuartersBase - 2 * f ); curveVertex( baseSize + 5 * f * a, threeQuartersBase - f ); curveVertex( baseSize + 5 * f * a, threeQuartersBase + f ); curveVertex( baseSize + 4 * f * a, threeQuartersBase + 2 * f ); curveVertex( baseSize + 3 * f * a, threeQuartersBase + 2 * f );
curveVertex( baseSize + 2 * f * a, threeQuartersBase + f ); curveVertex( baseSize + f * a, threeQuartersBase + f );
curveVertex( baseSize, threeQuartersBase + 2 * f );
curveVertex( baseSize, baseSize );
vertex( baseSize, baseSize );
//bottom curveVertex( baseSize, baseSize ); curveVertex( threeQuartersBase + 2 * f, baseSize ); curveVertex( threeQuartersBase + f, baseSize + f * b ); curveVertex( threeQuartersBase + f, baseSize + 2 * f * b ); curveVertex( threeQuartersBase + 2 * f, baseSize + 3 * f * b ); curveVertex( threeQuartersBase + 2 * f, baseSize + 4 * f * b ); curveVertex( threeQuartersBase + f, baseSize + 5 * f * b ); curveVertex( threeQuartersBase - f, baseSize + 5 * f * b ); curveVertex( threeQuartersBase - 2 * f, baseSize + 4 * f * b ); curveVertex( threeQuartersBase - 2 * f, baseSize + 3 * f * b );
curveVertex( threeQuartersBase - f, baseSize + 2 * f * b ); curveVertex( threeQuartersBase - f, baseSize + f * b );
curveVertex( threeQuartersBase - 2 * f, baseSize );
curveVertex( halfBase, baseSize );
vertex( halfBase, baseSize ); //left curveVertex( halfBase, baseSize ); curveVertex( halfBase, threeQuartersBase + 2 * f ); curveVertex( halfBase - f * c , threeQuartersBase + f ); curveVertex( halfBase - 2 * f * c, threeQuartersBase + f ); curveVertex( halfBase - 3 * f * c, threeQuartersBase + 2 * f ); curveVertex( halfBase - 4 * f * c, threeQuartersBase + 2 * f ); curveVertex( halfBase - 5 * f * c, threeQuartersBase + f ); curveVertex( halfBase - 5 * f * c, threeQuartersBase - f ); curveVertex( halfBase - 4 * f * c, threeQuartersBase - 2 * f ); curveVertex( halfBase - 3 * f * c, threeQuartersBase - 2 * f );
curveVertex( halfBase - 2 * f * c, threeQuartersBase - f ); curveVertex( halfBase - f * c, threeQuartersBase - f );
curveVertex( halfBase, threeQuartersBase - 2 * f );
curveVertex( halfBase, halfBase );
vertex( halfBase, halfBase );
vertex( halfBase, halfBase );
//top curveVertex( halfBase, halfBase ); curveVertex( threeQuartersBase - 2 * f, halfBase ); curveVertex( threeQuartersBase - f, halfBase - f * d ); curveVertex( threeQuartersBase - f, halfBase - 2 * f * d ); curveVertex( threeQuartersBase - 2 * f, halfBase - 3 * f * d ); curveVertex( threeQuartersBase - 2 * f, halfBase - 4 * f * d ); curveVertex( threeQuartersBase - f, halfBase - 5 * f * d ); curveVertex( threeQuartersBase + f, halfBase - 5 * f * d ); curveVertex( threeQuartersBase + 2 * f, halfBase - 4 * f * d ); curveVertex( threeQuartersBase + 2 * f, halfBase - 3 * f * d );
curveVertex( threeQuartersBase + f, halfBase - 2 * f * d ); curveVertex( threeQuartersBase + f, halfBase - f * d );
curveVertex( threeQuartersBase + 2 * f, halfBase );
curveVertex( baseSize, halfBase ); vertex( baseSize, halfBase ); endShape(CLOSE); }
void mousePressed() { a = random( -1, 1 ); b = random( -1, 1 ); c = random( -1, 1 );
d = random( -1, 1 );
a = a/abs(a); b = b/abs(b); c = c/abs(c); d = d/abs(d); }