[MWForum]large coordinates for "setpos" command

Wendy Petti mwforum@lists.mathcats.com
Mon, 13 Sep 2004 16:59:10 -0400


Hi Zehava,

Daniel offered you a procedure for calculating exactly where a turtle will
end up (given a certain projectsize) if you supply it with coordinates that
are larger than the limits of the project page.  But maybe we can also help
you with a simpler solution to your question, if what you're actually trying
to figure out is the outer coordinates of the project page.  In the Command
Center, type:

show projectsize

After you hit Enter/Return, you'll see two numbers below this command:  the
width and height of the project, in pixels.  Let's suppose your project is
480 x 420 (that's a small project but it will do for this example).  Since
home position is [0 0] in the middle of the page, we can divide each
dimension in half assume that there will be 240 pixels to the left and 240
pixels to the right to make 480 pixels in width overall, and that there will
be 210 pixels above and 210 pixels below the home position.

However, the [0 0] position actually occupies a pixel in width and height.
On a project with an even number of pixels in width and height, the 0
position for the x or y coordinates cannot actually be the exact center of
the page.  (At least this is what I'm assuming based on some experimenting
I've been doing just now.)

So setpos [-240 0] puts the turtle at the far left edge of the project page,
but setpos [240 0] does *not* put the turtle at the far right edge of the
project page; instead it appears at the left edge again.  setpos [239 0]
does put the turtle at the far right edge of the project page.  If you turn
the turtle into a line segment just one pixel in width, you will see it hugs
the right edge of the project page exactly.

But when we explore the top and bottom edges of this 480 x 420 page with a
turtle shaped as a horizontal line segment, setpos [0 210] puts the
line-segment turtle at the top of the page and setpos [0 -210] also puts the
turtle at the top of the page.  We need

So (for instance) if you wish to draw a border only one pixel thick exactly
around the outer dimensions of a project page, using the 480 x 420 example
you would need these commands:

pu setpos [-240 210]
pd setpos [239 210]
setpos [239 -209]
setpos [-240 -209]
setpos [-240 210]

Wendy