I would like to turn the following Schotter code into a rasterized image with this pattern. How do I go about translating the code an rasterized an image?
float lapse = 0; // mouse timer
int x = 10;
int y = 10;
float r = 0;
int s = 20; //square size
int rows = 90; //number of rows
int columns = 90; //number of columns
int margin = s*2; //margin of the
void setup() {
//size ((columns*s+margin*2), (rows*s+margin*2));
size(1112, 834);
colorMode(0);
background(255);
noLoop();
rectMode(CENTER); //uses center instead of left corner
}
void draw() {
for (int j = 10; j < height-margin*2; j = j+s) { //columns
fill(j/3, 200, 200, 60); //semi-transparent spectrum fill
for (int i = 10; i < width-margin*2; i = i+s) { //rows
pushMatrix(); //save this position for the origin
translate(i, j); //saves origin space as first box space
rotate(radians(random(-r, r))); //random rotations
r = r + .05; //rotational increment
rect(0+margin, 0+margin, s, s);
popMatrix(); //reference back to the initial origin saved...
//so translations and rotations dont stack/accumulate
}
}
}
Thank you @glv! Specifically, I need help connecting the angle of the square to the value of each pixel. The end product would be shifting transparent squares reacting to each pixel.
float lapse = 0; // mouse timer
int x = 10;
int y = 10;
float r = 0;
int s = 10; //square size
int rows = 120; //number of rows
int columns = 120; //number of columns
int margin = s*2; //margin of the
void setup() {
//size ((columns*s+margin*2), (rows*s+margin*2));
size(1112, 1000);
pixelDensity(2);
noFill();
background(255);
noLoop();
rectMode(CENTER); //uses center instead of left corner
}
void draw() {
for (int j = 10; j < height-margin*2; j = j+s) { //columns
noFill(); //semi-transparent spectrum fill
for (int i = 10; i < width-margin*2; i = i+s) { //rows
pushMatrix(); //save this position for the origin
translate(i, j); //saves origin space as first box space
rotate(radians(random(-r, r))); //random rotations
r = r + .002; //rotational increment
rect(0+margin, 0+margin, s, s);
popMatrix(); //reference back to the initial origin saved...
//so translations and rotations dont stack/accumulate
}
}
}