/*Erica D. Cochran Section B ericac@andrew.cmu.edu Copyright © Erica D. Cochran September 16, 2009 Carnegie Mellon University Exploring Programming with Graphics All Rights Reserved */ float x, y, eWidth,eHeight; void setup( ) { size(400, 400); smooth( ); background (250); frameRate(40); eWidth=.15*width; eHeight=.15*width; } void drawInitials(float x, float y, float iw, float ih) { //Letter E of initials noFill(); beginShape(); strokeWeight(1); stroke(250,70,150); curveVertex(x+(.3*iw),y+(.23*ih)); curveVertex(x+(.3*iw),y+(.23*ih)); curveVertex(x+(.2*iw),y+(.167*ih)); curveVertex(x+(.05*iw),y+(.33*ih)); curveVertex(x+(.175*iw),y+(.53*ih)); curveVertex(x+(.2*iw),y+(.58*ih)); curveVertex(x+(.2*iw),y+(.58*ih)); endShape(); //midpoint beginShape(); strokeWeight(1); stroke(250,40,100); curveVertex(x+(.2*iw),y+(.58*ih)); curveVertex(x+(.2*iw),y+(.58*ih)); curveVertex(x+(.175*iw),y+(.633*ih)); curveVertex(x+(.05*iw),y+(.833*ih)); curveVertex(x+(.2*iw),(y+ih)); curveVertex(x+(.3*iw),y+(.833*ih)); curveVertex(x+(.3*iw),y+(.833*ih)); endShape(); //Letter D //Vertical part of letter beginShape(); strokeWeight(1); stroke(255,200,70); curveVertex(x+(.375*iw),y+(.167*ih)); curveVertex(x+(.375*iw),y+(.167*ih)); curveVertex(x+(.425*iw),y+(.58*ih)); curveVertex(x+(.375*iw),y+ih); curveVertex(x+(.375*iw),y+ih); endShape(); //Curved part of letter beginShape(); strokeWeight(1); stroke(25,255,10); curveVertex(x+(.375*iw),y+(.167*ih)); curveVertex(x+(.375*iw),y+(.167*ih)); curveVertex(x+(.625*iw),y+(.58*ih)); curveVertex(x+(.375*iw),y+ih); curveVertex(x+(.375*iw),y+ih); endShape(); //Letter C //Top Swirl of C beginShape(); strokeWeight(1); stroke(105,100,255); curveVertex(x+(.96*iw),y+(.26*ih)); curveVertex(x+(.96*iw),y+(.26*ih)); curveVertex(x+(.975*iw),y+(.25*ih)); curveVertex(x+(.96*iw),y+(.23*ih)); curveVertex(x+(.95*iw),y+(.26*ih)); curveVertex(x+(.975*iw),y+(.3*ih)); curveVertex((x+iw),y+(.23*ih)); curveVertex((x+iw),y+(.23*ih)); endShape(); //Big curved protion of letter C beginShape(); strokeWeight(1); stroke(15,205,255); curveVertex((x+iw),y+(.23*ih)); curveVertex((x+iw),y+(.23*ih)); curveVertex(x+(.875*iw),y+(.167*ih)); curveVertex(x+(.7*iw),y+(.58*ih)); curveVertex(x+(.875*iw),y+ih); curveVertex((x+iw),y+(.83*ih)); curveVertex((x+iw),y+(.83*ih)); endShape(); //Bottom Swirl of C beginShape(); strokeWeight(1); stroke(105,100,255); curveVertex((x+iw),y+(.83*ih)); curveVertex((x+iw),y+(.83*ih)); curveVertex(x+(.975*iw),y+(.76*ih)); curveVertex(x+(.94*iw),y+(.8*ih)); curveVertex(x+(.945*iw),y+(.83*ih)); curveVertex(x+(.97*iw),y+(.82*ih)); curveVertex(x+(.965*iw),y+(.80*ih)); curveVertex(x+(.965*iw),y+(.80*ih)); endShape(); } void draw( ) { // These two lines of code cause the initials to fade out over time. fill( 0, 5 ); rect( 0, 0, width, height ); y = 0; drawInitials((frameCount % (width-eWidth)), y, eWidth, eHeight); y = (.85*height); drawInitials((width-eWidth) -(frameCount % (width-eWidth)), y, eWidth, eHeight); x=0; drawInitials(x, (width-eWidth)-(frameCount % (width-eWidth)), eWidth, eHeight); x=(.85*width); drawInitials(x, (frameCount % (width-eWidth)), eWidth, eHeight); drawInitials(random(.16*width,.15*width+width-2.5*eWidth), random(.16*height,.15*height+height-2.5*eHeight), random(.2*(width-2*eWidth),.35*(width-2*eWidth))-eWidth, random(.2*(height-2*eHeight),.35*(height-2*eHeight))-eHeight); //rect (.15*width,.15*height, width-2*eWidth, height-2*eHeight); //boundary } // This stops the repeated call of draw when the user presses the mouse button. void mousePressed( ) { noLoop( ); println("Animation stopped."); } // This restarts the repeated call of draw when the user presses any key on the keyboard. void keyPressed( ) { loop( ); println( "Animation re-started."); }