topical media & game development

talk show tell print

graphic-processing-algorithm-Ch09-p230-p230.pde / pde



  color[] shadeTable;
  void setColor(color c) {
    float r, g, b;
    r = red(c);
    g = green(c);   
    b = blue(c);  
    r /= 255.;
    g /= 255.; 
    b /= 255.;
    println(r);
    shadeTable = new color[256];
    for( int i = 0; i < 255; i++ )
      shadeTable[i] = color((int)(r*i),(int)(g*i),(int)(b*i));
  }
  
  void setup(){
    size(255,100);
    setColor(color(255,0,0));
    for( int i = 0; i < 255; i++ ){
      fill(shadeTable[i]);
      noStroke();
      rect(i,0,1,100);
    }
  }
  
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.