We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › pretty error
Page Index Toggle Pages: 1
pretty error (Read 615 times)
pretty error
Dec 26th, 2007, 5:01pm
I was trying to display a shadding-off with two colors
and i made an error that I'd like to share with you.
Just copy this code in a sketch. (You need to create a font).

void setup(){
size(600, 510);noStroke();background(100);
PFont f = loadFont("CenturyGothic-Bold-48.vlw");  //Arial-BoldMT-48.vlw");
void draw() {
text("// richard Monnier, école d'art d'Annecy.",110,80); text("// a misuse of color variable",110,20);text("// that yields more surprises",110,40);text("// than a right use of a random function",110,60);

color a = color(mouseY/2, 0, 0);fill(a);String rou = str(a);
text("color COLOR1 = color(mouseY, 0, 0);        //result :" + rou,110,120);
color b = color(0, 0, mouseY/2);fill(b);String bleu = str(b);
text("color COLOR2 = color(0 ,0 ,mouseY);             //result :" + bleu,110,140);
text(" for(int i = 1; i<height; i=i+1",110,180);
text(" { ",110,200);
text("// Here it is the use of the color variable as a common number : ",110,220);
text(" fill ((( COLOR1 + COLOR2 )/height)*i);",110,260);

for(int i=1; i<255; i=i+1) {
rect(0,i*2,100,(i*2)+2);    }  
fill((a+b)/height); String unit = hex((a+b)/height);

text("// fortunately, Processing find a color in this result: " + unit,110,300);
text(" rect(0,i,100,i+1);                              //displaying the color",110,340);
text(" } ",110,360);

Page Index Toggle Pages: 1