/** * Drawing a star. * *

Elie Zananiri
* CART 253, Winter 2008

*/ void setup() { size(400, 400); smooth(); noStroke(); } void draw() { background(0); // 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(); }