Book a Demo

Author Topic: Where is the origin in the shape scripts coordinate region?  (Read 3120 times)

mse

  • EA User
  • **
  • Posts: 308
  • Karma: +1/-0
    • View Profile
Where is the origin in the shape scripts coordinate region?
« on: February 26, 2020, 12:25:35 am »
I was looking at some sample scripts and trying to understand the coordinate system when using commands like moveto and lineto. Where is 0,0 for example on a screen? I assume the units are always in pixels. I searched the documentation using "coordinates" or something similar but I couldn't find anything.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Where is the origin in the shape scripts coordinate region?
« Reply #1 on: February 26, 2020, 08:28:07 am »
For shape scripts, the numbers used in the drawing commands are a percentage of the selection rectangle of the element. So (0,0) will be the top left corner, (100,100) the bottom right corner. You can extrapolate to draw outside the rect, e.g. rectangle(-10,-10,110,110);

The Sparx Team
[email protected]

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Where is the origin in the shape scripts coordinate region?
« Reply #2 on: February 26, 2020, 09:53:33 am »
You can extrapolate to draw outside the rect, e.g. rectangle(-10,-10,110,110);
But be aware that if you do this it will break any bounding rects required by your element. So your elements may be cut off in documentation etc.