I am trying to figure out how to access the 5 grays in the array randomly to fill() the arc shape and rectangle.
Seems like it should be pretty easy to do but…
And haven’t been able to find anything in my books or online that has worked yet.
I’ve commented next to problem areas.
Any hints / guidance most welcome!
// halfmoon motif
import processing.pdf.*;
boolean record;
color c1 = #FFFFFF;
color c2 = #BEBEBE;
color c3 = #7F7F7F;
color c4 = #3F3F3F;
color c5 = #000000;
color [] grays = {c1, c2, c3, c4, c5};
float deg = 90; // 90 degrees
float rad = radians(deg); // convert to radians
void setup() {
size(400, 400);
//______________________??? I should somehow initialize the array list here ???
grays [0] = #FFFFFF; // kind of lost here
grays [1] = #BEBEBE;
grays [2] = #7F7F7F;
grays [3] = #3F3F3F;
grays [4] = #000000;
//grays = new color (grays.length);
//for (int c = 0; c < grays.length; c++)
//______________________________???
frameRate(1);
}
void draw() {
if (record) {
beginRecord (PDF, "frame-####.pdf");
}
background (127);
noStroke();
float r = random(1);
println (r);
translate (200, 200);
if (r < 0.40) {
rotate (rad);
} else if (r > 0.40 && r < 0.50) {
rotate (rad*3);
} else if (r > 0.50 && r < 0.65) {
rotate (rad*2);
} else {
rotate (rad*4);
}
fill (int(random(grays))); // wrong, Would like a random selection from gray array list
rectMode (CENTER);
rect (0, 0, 200, 200);
fill (grays); // wrong, Would like a random selection from gray array list
arc (0, -100, 200, 200, 0, PI);
if (record) {
endRecord();
record = false;
}
}
void mousePressed() { // make PDF of current frame
record = true;
}