/** * Drawing a star. * *

Elie Zananiri
* CART 253, Winter 2008

*/ void setup() { size(400, 400); smooth(); noStroke(); } void draw() { // draw a semi-transparent rect to cover the whole canvas // this will give the stars that "fading" effect fill(0, 10); rect(0, 0, width, height); // draw a star at the current mouse position with size relative to the mouse movement fill(216, 61, 4); int avgMove = int((abs(pmouseX-mouseX)+abs(pmouseY-mouseY))/2); drawStar(mouseX, mouseY, avgMove*5); } void drawStar(int xPos, int yPos, int starSize) { beginShape(); vertex(xPos, yPos-starSize/2); vertex(xPos-starSize/3, yPos+starSize/2); vertex(xPos+starSize/2, yPos-starSize/8); vertex(xPos-starSize/2, yPos-starSize/8); vertex(xPos+starSize/3, yPos+starSize/2); vertex(xPos, yPos-starSize/2); endShape(); }