Changing colours through a set array

R_BR_B
edited December 2015 in Questions about Code

I'm trying to change the colours within a set of rotated rectangles using an array of set colours

I can get the colours to change as a strobe using fill(ccolor[(int)random(ccolor.length)]); but I would like each colour to be assigned to a rectangle and stay with it.

I've done lots of internet searching but can't find anything that helps me!

//VARIABLES
float sqsize=350;
float rangle;
color [] ccolor=``{color(190,75,90),color(240,160,100),color(250,210,80),color(145,180,70),color(80,180,90),color(170,125,185) };

//SETUP
void setup()
{
size(550,550);
smooth();
rectMode(CENTER);
}

//DRAW
void draw()
{
background(255);  
translate(width/2,height/2);
float cmousex=float(mouseX);
rangle=(cmousex/width)*(PI/2);
println(mouseX);
println(rangle);


for (int i=0;i<200;i++)
{
rect(0,0,sqsize,sqsize);
fill(ccolor[i]);
rotate(rangle);
sqsize=sqsize*cos(rangle);
}
sqsize=350;
}
Tagged:

Answers

Sign In or Register to comment.