/** * LlamaLlight. * Based on the iPhone Application "LlamaLlight". *
* Click in the central box to set colour. *
* Horizontal is hue. Vertical is saturation and darkness. *
* Click more than 4 times to blink through the clicked colours. * */ PImage redLlama; PImage whiteLlama; PImage blackLlama; TimeEventList tel; int sz = 100; // our setup routine void setup() { // set up screen size(480, 480); frameRate( 60 ); colorMode(HSB, sz*2, sz, sz); noFill(); // set up images/llama icon rendering imageMode( CORNER ); redLlama = loadImage( "RedLlama.png" ); whiteLlama = loadImage( "WhiteLlama.png" ); blackLlama = loadImage( "BlackLlama.png" ); // set up our time event list, with the specified size tel = new TimeEventList( sz ); } // shortcut to draw a drop-shadowed llama to the screen void drawLlama( PImage which ) { int sx = (width/2) - (blackLlama.width/2); int sy = (height/2) - (blackLlama.height/2); image( blackLlama, sx+1, sy+1 ); image( which, sx, sy ); } // hook into the mouse events... void mouseReleased() { tel.mouseReleased(); } void mousePressed() { tel.mousePressed(); } void mouseDragged() { tel.mouseDragged(); } void drawTargetBox() { stroke( 0, 32 ); rect( (width/2)-sz, (height/2)-sz, sz*2, sz*2 ); } void drawLlamas() { // and draw the llama if we're within the correct timeframe if( tel.extendedDrag == false ) { drawLlama( whiteLlama ); } else { drawLlama( redLlama ); } } void draw() { /* set the background color according to what the TimeEventList tells us */ background( tel.getColor() ); /* draw the llama and send zero-motion drag events */ if( mousePressed ) { tel.mouseDragged(); // force zero motion drag events drawTargetBox(); // draw the target box drawLlamas(); // draw the llamas } else { tel.mouseIdle(); // mouse is unclicked } //tel.debugPrint(); // output to help with debugging }