• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Finding and storing x and y coordinates

New Here ,
Feb 02, 2009 Feb 02, 2009

Copy link to clipboard

Copied

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?
TOPICS
Programming

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 02, 2009 Feb 02, 2009

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 05, 2009 Feb 05, 2009

Copy link to clipboard

Copied

Yes, you are right.

Helge

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 06, 2010 Jun 06, 2010

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines