//This code is of a magical little squirrel that I have //named Lyf (said "leaf") and Lyf's amazing magical abilities //were coded by: Sara Mattice, Friday October 23, 2009 //With Mrs. Reiser's help too :D //all of my variables //a lot of these deal with my magical rings, the last four do int h = 0, dimension; float s = 1; PImage squirrel; float y=50.0; float speed=10.0; float radius=5.0; int direction=1; //this creates the Ring class, what draws the magical circles //when the mouse is pressed, this is used to draw the rings class Ring { float x, y; float diameter; boolean on=false; void start(float xpos, float ypos){ x=xpos; y=ypos; on=true; diameter=.1; } //makes the rings expand and vanish when they have radius=15; void grow(){ if (on==true) { diameter+=.5; if(diameter>15){ on=false; } } } //this is what shows in the display when the //magical loops are activated :) void display(){ if (on==true){ //these are my magical circles! fill(174,28,219,110); stroke(179,20,199,90); ellipse(x,y,(diameter)/3,(diameter)/3); ellipse(x+20,y+20,(diameter-2)/4,(diameter-2)/4); ellipse(x+30,y+7,(diameter-6)/2,(diameter-6)/2); ellipse(x+6,y+30,(diameter-8)/2.5,(diameter-6)/2.5); } } } //how many rings I have, I think //I'm not entirely sure what it does, but its important. Ring[] rings; int numRings=90; int currentRing=0; //this is my setup function, declaring things like noCursor //colorMode, size, the squirrel background, etc //It sets the dimensions for the main pixel array too. void setup() { noCursor(); size(488,400); colorMode(HSB,360,100,100); noStroke(); smooth(); squirrel = loadImage("squirrel5.jpg"); //load squirrel-y background dimension = squirrel.height * squirrel.width; image(squirrel,0,0); ellipseMode(RADIUS); rings = new Ring[numRings]; for (int i=0; i55) squirrel.pixels[(j*width)+i]=color((hue(squirrel.pixels[(j*width)+i])+30)%360, saturation(squirrel.pixels[(j*width)+i]), brightness(squirrel.pixels[(j*width)+i])); } } } //this updates the pixels after the m key is pressed, //I think... squirrel.updatePixels(); image(squirrel, 0, 0); } //draws the magical circles when the mouse is moved and //makes sure the rings follow the mouse coordinates, //while also stopping if it gets above numRings... //I think... void mouseMoved(){ rings[currentRing].start(mouseX,mouseY); currentRing++; if (currentRing >= numRings){ currentRing=0; } }