feat: normalized window position relX/relY relative to viewport (no infinite-canvas coords)
This commit is contained in:
1 parent
153da94fde
commit
b57cda16ec
2 files changed
+15
No files matched your search
@@ -57,6 +57,7 @@ function Plugin () {
|
||||
viewport: { x: number; y: number; width: number; height: number }
|
||||
maxViewport: { width: number; height: number }
|
||||
gapL: number; gapR: number; gapT: number; gapB: number
|
||||
relX: number; relY: number
|
||||
center: { x: number; y: number }
|
||||
} | null>(null)
|
||||
const [copied, setCopied] = useState(false)
|
||||
@@ -86,6 +87,7 @@ function Plugin () {
|
||||
viewport: { x: number; y: number; width: number; height: number }
|
||||
maxViewport: { width: number; height: number }
|
||||
gapL: number; gapR: number; gapT: number; gapB: number
|
||||
relX: number; relY: number
|
||||
center: { x: number; y: number }
|
||||
}) {
|
||||
setWindowInfo(info)
|
||||
@@ -117,6 +119,8 @@ function Plugin () {
|
||||
`figma.viewport.bounds = ${i.viewport.x},${i.viewport.y} · ${i.viewport.width}×${i.viewport.height}`,
|
||||
`lastSize.width = ${i.width}`,
|
||||
`lastSize.height = ${i.height}`,
|
||||
`relX = ${i.relX} (x − bounds.x)`,
|
||||
`relY = ${i.relY} (y − bounds.y)`,
|
||||
'',
|
||||
'== РАСЧЁТ · в main.ts ==',
|
||||
`gapL = ${i.gapL} (x − bounds.x)`,
|
||||
@@ -284,6 +288,8 @@ function Plugin () {
|
||||
<Field name="lastSize.width" value={windowInfo.width} />
|
||||
<Field name="lastSize.height" value={windowInfo.height} />
|
||||
<Field name="maxViewport (bounds·zoom)" formula="bounds.width*zoom, bounds.height*zoom" value={`${windowInfo.maxViewport.width}×${windowInfo.maxViewport.height}`} />
|
||||
<Field name="relX (x − bounds.x)" formula="нормализованная X окна в viewport" value={windowInfo.relX} />
|
||||
<Field name="relY (y − bounds.y)" formula="нормализованная Y окна в viewport" value={windowInfo.relY} />
|
||||
</Section>
|
||||
{/* Расчётные — посчитаны в main.ts из вышеперечисленных raw-значений */}
|
||||
<Section title="РАСЧЁТ · в main.ts">
|
||||
|
||||
Reference in new issue
Block a user