Skip to main content
Participating Frequently
February 2, 2009
Question

Finding and storing x and y coordinates

  • February 2, 2009
  • 2 replies
  • 1502 views
I need to somehow store a given set of x & y coordinates into a def. When I draw a path to a certain point, the program needs to store that point in a def to use it later on. For instance, the program will be deciding whether to draw a line to the left or to the right, depending on whether or not it's x value is greater than (to the right of) the center of the page, or less than (to the left of) the center.

the logic is as such:

{
Draw a circle with circleX and circleY as the center
Draw a line from the edge of the circle out 10 points
Now after you draw this line, where are you (what is your x,y)?
Store those x,y coordinates into defs named previousX, and previousY.
if previousX is greater than or equal to circleX, then draw a
line to the right. If not, then draw a line to the left.
}

I have been using currentpoint with success when creating a new origin point for arcs and whatnot, but something like

/previousPoint currentpoint def

just doesn't work. I also cannot compare currentpoint with circleX and get any helpful return.

Anyone know a good way to "get" the x and or y at the current point?
This topic has been closed for replies.

2 replies

Participating Frequently
February 5, 2009
Yes, you are right.

Helge
Inspiring
June 6, 2010

and to save y

/CurrentY currentpoint exch pop def

this will save Y position

to save them both in one shot procedure

/CurrentPOS

{

currentpoint /CurrentY exch def   /CurentX exch def

} def

Participating Frequently
February 2, 2009
Update:

tentatively,

/previousX currentpoint pop def

seems to work, at least for my purposes here. Could have sworn that was not before. Please someone show me if there is a better way, or if my thinking is wrong. I am assuming that currentpoint pushes x and then y on the stack, so in order to get x, you have to pop y off.