/** * Carnival Lights * By Raphael Rouvinov-Kats * * What's up Sherry :D * */ frameRate(35); colorMode(HSB); var armLen = 20; var arms = 11; textAlign(CENTER); textSize(60); var ts = 60; var message = [ "♥", "Dear papa", "You are a fantastic father", "We want to thank you", "For all the love and support you give us", "For blessing us with your presence every day", "For your hard work and humor, \nyour stories and smile", "We love you", "Happy Father's Day", "♥" ]; var draw = function() { background(148, 145, 80); for(var ang = 0; ang < 360; ang += 360/arms) { pushMatrix(); translate(200, 200); rotate(ang + frameCount*2); for(var c = 0; c < armLen; c++) { var x = map(c, 0, armLen, -200 * sqrt(2), -146); var y = 0; if(c % 2 === 0) { // white stroke(0, 0, 90); if((frameCount + c) % 6 < 3) { fill(0, 0, 255); // on } else { fill(0, 0, 90); // off } } else { // red stroke(255, 255, 90); if((frameCount + c) % 6 < 3) { fill(255, 255, 255); // on } else { fill(255, 255, 90); // off } } ellipse(x, y, 10, 10); } popMatrix(); } pushMatrix(); translate(200, 200); var secondsPerMsg = 5; var framesPerMsg = this.__frameRate * secondsPerMsg; var index = floor( map(frameCount, 0, message.length*framesPerMsg, 0, message.length) ); index = constrain(index, 0, message.length - 1); var txt = message[index]; if(index === 0 || index === message.length - 1) { rotate(frameCount); textAlign(CENTER); textSize(60); ts = 60; } else { textAlign(CENTER); //println(textWidth(txt) + " " + (textWidth(txt)-width)/2); //if(textWidth(txt) < width) { ts+= (width-textWidth(txt))/2; } //if(textWidth(txt) > width) { ts-= (textWidth(txt)-width)/2; } textSize(18); } text(txt, 0, 20); popMatrix(); };