Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float d=30;
- int num=300, edge=150, rs, f;
- void setup() {
- colorMode(HSB, 360, 100, 100);
- size(1000, 800);
- background(#202020);
- }
- void draw() {
- }
- void mouseClicked() {
- background(20);
- f = (int) random(360);
- rs = (int) random(10000);
- for (int i=0; i<num; i++) {
- drawIsoCube();
- }
- }
- void keyPressed() {
- saveFrame("image-###.gif");
- }
- void drawIsoCube() {
- //f = (int) random(360);
- int orgX, orgY;
- int[] x = new int[7];
- int[] y = new int[7];
- int w = int(cos(radians(30))*d);
- int h = int(sin(radians(30))*d);
- int rx = (int) random(width/d);
- int ry = (int) random(height/d);
- if (random(1)>.5) {
- orgX=rx*w*2;
- orgY=ry*h*2;
- } else {
- orgX=w+rx*w*2;
- orgY=(ry*h*2)+h;
- }
- if (orgX<edge || orgX>width-edge || orgY<edge || orgY>height-edge) {
- } else {
- x[0]=orgX;
- y[0]=orgY;
- x[1]= x[0];
- y[1]= int(y[0]+d);
- x[2]= int(x[1]-w);
- y[2]= int(y[1]-h);
- x[3]= x[2];
- y[3]= int(y[2]-d);
- x[4]= x[0];
- y[4]= int(y[0]-d);
- x[5]= int(x[0]+w);
- y[5]= int(y[0]-h);
- x[6]= x[5];
- y[6]= int(y[5]+d);
- stroke(#202020);
- noStroke();
- fill(f, 90, 60);
- quad(x[0], y[0], x[1], y[1], x[2], y[2], x[3], y[3]);
- fill(f, 90, 90);
- quad(x[0], y[0], x[3], y[3], x[4], y[4], x[5], y[5]);
- fill(f, 90, 40);
- quad(x[0], y[0], x[5], y[5], x[6], y[6], x[1], y[1]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement