Skip to main content
Solved

I want to get the same coordinate values as the exported image using the Plugin API

  • January 17, 2024
  • 1 reply
  • 416 views

yoshio

Hi All.

How can I get the layer coordinates (X,Y) of an exported image from the Plugin API?
If the value is a decimal number, the coordinates of the exported image and the coordinates obtained by the Plugin API are different. The layer coordinates of the exported image are integers.

I want you to look at the file you uploaded.
Example_Ellipse.fig (19.3 KB)

S__S1.png is the exported image. The position of each layer in the exported image is as follows
IMG__Rect1 layer X=701
IMG__Rect2 layer X=800

Figma UI settings are as follows
S__S1 layer X=-961
IMG__Rect1 layer X=700.99
IMG__Rect2 layer X=800.01

The Plugin API (absoluteTransform) settings are as follows
S__S1 layer X=-961
IMG__Rect1 layer X=-260.010009765625
IMG__Rect2 layer X=-160.989990234375

Is this the formula I came up with correct?

  • In case of calculating X of IMG__Rect1 layer
    ① 700.99 = -260.010009765625(X of IMG__Rect1 layer) - -961(X of S__S1 layer)
    ② 701 = Math.round(700.99)
  • In case of calculating X of IMG__Rect2 layer
    ① 800.01 = -160.989990234375(X of IMG__Rect2 layer) - -961(X of S__S1 layer)
    ② 800 = Math.round(800.01)

Best answer by yoshio

Self resolved.
The formula I came up with was generally correct.

View original
This topic has been closed for replies.

yoshio
  • New Participant
  • February 29, 2024

Self resolved.
The formula I came up with was generally correct.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings