
<-----Old colour scheme
New colour scheme------>
NEW CODE:
//change these to get pretty pictures
int xRepeat = 10;
int yRepeat = 10;
int x = 0; // xpos
int y = 0; // ypos
int w = 50; // width of rect
int h = 50; // height of rect
int s = 0; // random stroke size less than this number
void setup() {
size(500, 500);
smooth();
background(255);
for (int i = -10; i < width/xRepeat; i++) {//loop 1 repeats pattern in the x direction.
for (int j = -10; j < height/yRepeat; j++) {//loop 2 repeats the entire rows vertically.
pushMatrix();//saves untransformed co-ordinates
translate(xRepeat*i, yRepeat*j);// translates the entire coordinate system (is what causes the same thing to be drawn in different places).
myPattern();
popMatrix();//reverts to the saved co-ordinate system that we created using pushMatrix()
}
}
}
//ignore draw this time. use the "myPattern()" function instead
void draw() {
}
void myPattern() {
strokeWeight(random(s));
color col = color(255, 170, 0);
color col2 = color(18, 64, 171);
color finalColor = lerpColor(col, col2, random(0, 1));
fill(finalColor);
rect(random(x), random(y), w, h);
}
void mousePressed() {
save("p2_53.jpeg");
}

No comments:
Post a Comment