/* diamond.pde Written by Justin Hsia Change a function to draw a custom diamond shape and then draw three colored diamonds using it. */ // draw a diamond centered at (x,y) // with width w and height h. void diamond(float x, float y, float w, float h) { beginShape(); vertex(x , y-h/2); // top vertex vertex(x+w/2, y ); // right vertex vertex(x , y+h/2); // bottom vertex vertex(x-w/2, y ); // left vertex vertex(x , y-h/2); // close shape endShape(); } void setup() { size(500,500); // square canvas background(255); // white background } void draw() { fill(255,0,0); // red diamond( 50, 50,100,100); // diamond in upper-left corner fill(0,255,0); // green diamond(250,250,100,100); // diamond in center fill(0,0,255); // blue diamond(450,450,100,100); // diamond in lower-right corner }