Code
ColoredRect cr;
void setup(){
size (300, 300);
cr = new ColoredRect(LEFT, 1.0);
}
void draw(){
background(0);
cr.render();
chooseMyColor();
drawMyRect();
}
void chooseMyColor(){
// You can ask the ColoredRect various questions about itself
float crRed = cr.getRed(); // returns a value from 0...1
float crGreen = cr.getGreen(); // returns a value from 0...1
float crBlue = cr.getBlue(); // returns a value from 0...1
float crHue = cr.getHue(); // returns a value from 0...1
float crSat = cr.getSat(); // returns a value from 0...1
float crBri = cr.getBri(); // returns a value from 0...1
float crWidth = cr.getWidth(); // returns a value from 0...1
// here is where you would set the fill color for your part,
// the right hand side of the canvas.
// here's where you would compute your new color, based on the properties of the CR.
// here's a simple example, which produces a lighter version of the CR's color:
colorMode(RGB, 1.0);
float r = crRed+crWidth/2;
float g = crGreen+crWidth/2;
float b = crBlue+crWidth/2;
println("R:"+crRed+" G:"+crGreen+" B:"+crBlue);
println("H:"+crHue+" S:"+crSat+" Br:"+crBri);
fill(r,g,b);
}
void drawMyRect(){
// don't touch this
float crw = width * cr.getWidth();
rect (crw,0, width-crw, height);
}
040 -- Computational Color I: Due 10/20
Statement:Download this Processing project, and install it into your sketchbook. This program automatically changes the color and size of a rectangle on the left hand side of the canvas. Your objective is to set the color of the rectangle on the right hand-side of the canvas, so that it always presents a "pleasing complement" (whatever that means to you) to the changing left-hand rectangle. You are not permitted to change the code governing the left-hand rectangle. [This is a small exercise!]
If you would like a slightly more difficult challenge, this related project asks you to derive a color which serves to "negotiate the space" in between two randomly-changing colored regions.