Loading...
Logo
Processing Forum
Here is the code

Copy code
  1. int w = 255;
    int h =255;

    PImage ax, bx, cx, dx;
    int rr=255;
    int gg=0;
    int bb=0;

    void setup() {

      size(w, h);
      ax=createImage(w, h, ARGB);


      for (int y=0;y<h;y++) {

        for (int x=0;x<w;x++) {





          if (x==y) {

            bb=x;
          }
          rr--;
          gg++;

          ax.set(x, y, color(rr, gg, bb));
        }
        rr=255;
        gg=0;
      }
      image(ax, 0, 0);
    }

    void draw() {
      color c = ax.get(mouseX, mouseY);
      rr = c>>16&255;
      gg = c>>8&255;
      bb = c&255;
      this.frame.setTitle(str(rr)+ " "+str(gg)+ " "+ str(bb));
    }

I want to crate a RGB box where each corner has the highest red,green and blue i.e. 255. I have the two top corner as red and green but the blue corner still has green in it. The fourth corner I want to be 255,255,255

Can anyone help ?

Here is an image of what I have so far.


This is what I want to achieve

Replies(2)

Copy code
  1. size(255,255);
  2. for(int y=0;y<height;y++){
  3.   for(int x=0;x<width;x++){
  4.     stroke(255-x,abs(x-y),y);
  5.     point(x,y);
  6.   }
  7. }
... Huh...

Copy code
  1. size(255,255);
  2. for(int y=0;y<height;y++){
  3.   for(int x=0;x<width;x++){
  4.     stroke(255-x,255-abs(y-(255-x)),y);
  5.     point(x,y);
  6.   }
  7. }
I guess you need to be more specific...!
Thanks buddy that worked !