//Derek Lovett //Oct 27, 2009 //Assignment 6 float radius = 1.0;//defining variables int h = 0, dimension; PImage img; void setup() {//runs once size(500,500);//sets screen size background(255);//sets background color to white colorMode(HSB,360,100,100);//sets color mode noStroke();//turns off stroke smooth();//turns of antialiasing img = loadImage("green_apple.jpg"); //load apple image dimension = img.height * img.width; image(img,0,0,height,width); frameRate(10000);//sets framerate } void draw() {//keeps motor running } //keypressed event changes color of apple void keyPressed() {//initiates keypress event if (key == 'h') {//sets keypress event to "h" key img.loadPixels(); //increments hue 60 degrees // % makes sure hue never grows beyond 360 for (int i=0; i < dimension; i++) { img.pixels[i] = color((hue(img.pixels[i])+40)%360, saturation(img.pixels[i]), brightness(img.pixels[i])); } img.updatePixels(); image(img, 0, 0,height,width); } }