> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://studio.sketchpad.cc/sp/pad/view/ro.QeRAa8KjcMt/rev.19
 * 
 * authors: 
 *   GoToLoop

 * license (unless otherwise specified): 
 *   creative commons attribution-share alike 3.0 license.
 *   https://creativecommons.org/licenses/by-sa/3.0/ 
 */ 



// http://Forum.Processing.org/topic/processing-question
// http://Forum.Processing.org/topic/generate-a-square-grid
// http://Studio.ProcessingTogether.com/sp/pad/export/ro.9PDcp7xMBknWz

static final byte SQUARES = 4;
static final color[] colors = new color[SQUARES];

// Choose JAVA2D, FX2D, P2D, P3D or OPENGL:
static final String ENGINE = JAVA2D;

void setup() {
  size(512, 512, ENGINE);

  smooth(3);
  frameRate(60);
  noLoop();

  noCursor();
  noStroke();

  colorMode(RGB);
  rectMode(CORNERS);  // CORNER also works here!

  mousePressed();
}

void draw() {
  fill(colors[0]);
  rect(0, 0, mouseX, mouseY);

  fill(colors[1]);
  rect(mouseX, 0, width, mouseY);

  fill(colors[2]);
  rect(0, mouseY, mouseX, height);

  fill(colors[3]);
  rect(mouseX, mouseY, width, height);
}

void mousePressed() {
  for (int c = SQUARES; c-- != 0; colors[c] = (int) random(~~#000000));
  print(hex(colors[0]) + '\t');
  redraw();
}

void mouseMoved() {
  redraw();
}

void mouseDragged() {
  redraw();
}