//import processing.opengl.*; color comp = color(255, 255, 192); Shape s1, s2, s3, s4; void setup() { //size(640,480,OPENGL); size(640,480); s1 = new Shape(100, 100); s2 = new Shape(540, 100); s3 = new Shape(100, 380); s4 = new Shape(540, 380); } void draw() { background(255); draw_circle(); draw_shapes(); } void draw_circle() { noStroke(); fill(comp); ellipse(mouseX, mouseY, 100, 100); framerate(60); } void draw_shapes() { s1.be(); s2.be(); s3.be(); s4.be(); } class Shape { float x,y,s; boolean sel = false; color f = color(0, 0, 192); float a = 0; Shape(float $x, float $y) { x = $x; y = $y; s = 20; a = random(TWO_PI); } void be() { move(); listen(); draw(); } void move() { x += cos(a)*.5; y += sin(a)*.5; wrap(); } void wrap() { if (x < 0-s) { x = width+s; } else if (y < 0-s) { y = height+s; } else if (x > width+s) { x = 0-s; } else if (y > height+s) { y = 0-s; } } void draw() { if (sel) { fill(f); } else { fill(192); } ellipse(x, y, s, s); } void listen() { //color c = get((int)x, round(height-y)); color c = get((int)x, (int)y); if (red(c) == red(comp) && green(c) == green(comp) && //blue(c) == blue(comp)+1) { blue(c) == blue(comp)) { sel = true; } else { sel = false; } } }