Reverse engineer a list of primitive shape drawing instructions for the diagram below.

size(10,10);
stroke(0);
point(1,1);
line(1,5,1,9);
line(0,9,6,3);
rect(4,1,6,3);
ellipse(7,8,4,3);
Note: this exercise could probably be improved by having an ellipse in the bottom right with a more obvious center pixel.

5 Comments

»

  1. Isn’t the ellipse supposed to be, ellipse(6,7,4,3)?

    Comment by jason — March 7, 2009 @ 3:50 pm

  2. Default ellipse mode is “CENTER” meaning the registration point of the ellipse is the center. You are right thought, that CORNER mode would be more clear and so you could revise the answer to be:

    ellipseMode(CORNER);
    ellipse(6,7,4,3);
    

    Comment by admin — March 8, 2009 @ 6:52 am

  3. Looking at line (0,9,6,3); I would of thought the answer to be line (0,9,5,4); as it’s not obvious that the line is attached to the square.

    Comment by Dolsign — January 7, 2010 @ 7:36 am

  4. Indeed, that is probably a better solution, either way is technically correct.

    Comment by Daniel Shiffman — January 7, 2010 @ 8:20 am

  5. There is also possible to be,
    ellipse Mode (CORNERS);
    ellipse (6,7,9,9)

    Comment by Sok Lin — February 17, 2010 @ 6:08 pm

Leave a comment