Answer:

  • Pete

    ellipse (3,7,4,4);

    should be…
    ellipse (3,7,5,5);
    based upon figure 1.10 in book.

    Yes? No?

  • Pete

    rect (5,0,4,3);

    should be…
    rect (5,0,5,4);
    based upon figure 1.7 in book.

    Yes? No?

  • admin

    Yes, technically you are correct. However, it is physically impossible to have an ellipse with a perfect center at (3,7) with an “even” width. So Processing approximates. I didn’t mean for this to be a trick question, however, and it’s really an oversight on my part. The exercise would be a lot clearer with (3,7,5,5). Nevertheless, the above result is exactly how Processing would do it (the answer was generated with Processing itself!).

  • admin

    Re: rect(5,0,4,3). This is another excellent point. Really, you are correct. I’m not sure why Processing generated the rectangle one pixel higher. Most likely, this is due to the fact the Processing puts the outline of a shape on the outside pixel (i.e. the interior width is 4, so the line falls on the 5th pixel). This is mostly an artifact of looking at this shapes zoomed in.

  • Lun Chanmaranden

    sum=0
    for(i=1;i<=n;i++)
    sum=sum+i;

  • Natalie

    For rectify(5,0,4,3) in corners mode, wouldn’t (4,3) as the supposed “bottom right corner” produce an error since it is to the left of the top left corner (5,0)? I don’t understand the diagrammed rectangle in the answer but am I just completely missing something?

  • Natalie

    Whoops autocorrect I meant rect not rectify

  • Natalie

    Just realized there’s a difference between rect(CORNER) and rect(CORNERS) so disregard previous questions…. However the rectangle in the answer seems to be rect(5,0,5,4) – 1 pixel larger on each side?

  • Anonymous

    Yes, technically, you are correct. I’m not sure why Processing generated the rectangle one pixel higher. Most likely, this is due to the fact the Processing puts the outline of a shape on the outside pixel (i.e. the interior width is 4, so the line falls on the 5th pixel). This is mostly an artifact of looking at this shapes zoomed in.