Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int[] xAnchors = new int[4];
- int[] yAnchors = new int[4];
- int columns = 12;
- int rows = 8;
- int columnWidth;
- int rowHeight;
- int frameSize = 40;
- ArrayList shapes = new ArrayList();
- void setup(){
- size(900, 600, P3D);
- columnWidth = (width - frameSize)/columns;
- rowHeight = (height - frameSize)/rows;
- generate();
- }
- void generate(){
- shapes.clear();
- for(int c = 0 ; c < columns ; c++){
- for(int r = 0 ; r < rows ; r++){
- shapes.add(makeShape());
- }
- }
- }
- PShape makeShape(){
- xAnchors[0] = (int)random(columnWidth/2);
- xAnchors[1] = (int)random(columnWidth/2) + columnWidth/2;
- xAnchors[2] = (int)random(columnWidth/2) + columnWidth/2;
- xAnchors[3] = (int)random(columnWidth/2);
- yAnchors[0] = rowHeight/2 + (int) random(rowHeight/8, -(rowHeight/8));
- yAnchors[1] = (int)random(rowHeight/2);
- yAnchors[2] = rowHeight/2 + (int) random(rowHeight/8, -(rowHeight/8));
- yAnchors[3] = (int)random(rowHeight/2) + rowHeight/2;
- PShape shape = createShape();
- shape.beginShape();
- shape.stroke(50);
- shape.noFill();
- shape.vertex(xAnchors[0], yAnchors[0]);
- shape.bezierVertex(xAnchors[0], yAnchors[0], xAnchors[1], yAnchors[1], xAnchors[2], yAnchors[2]);
- shape.stroke(100);
- shape.bezierVertex(xAnchors[2], yAnchors[2], xAnchors[3], yAnchors[3], xAnchors[0], yAnchors[0]);
- shape.endShape();
- return shape;
- }
- void draw(){
- background(#e0ded5);
- int index = 0;
- for(int c = 0 ; c < columns ; c++){
- for(int r = 0 ; r < rows ; r++){
- PShape aShape = (PShape)shapes.get(index);
- shape(aShape, frameSize/2 + columnWidth * c , frameSize/2 + rowHeight * r);
- index++;
- }
- }
- noLoop();
- }
- void mousePressed(){
- generate();
- loop();
- }
Add Comment
Please, Sign In to add comment