Skip to content

AI-native design editor. Open-source Figma alternative.

fix(canvas): resize and rotate a selection where Figma's zones are (#1092)

Danila Poyarkovcff48b159911
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a992409a5..527c502a7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,14 @@
## Unreleased
+### Breaking changes
+
+- `CORNER_ROTATE_ZONE` is removed from `@open-pencil/core/constants`; the selection's resize and rotation zones are `TRANSFORM_ZONE` and `transformZoneAt` in `@open-pencil/core/geometry`, which also owns the `HandlePosition` and `CornerPosition` types.
+
+### Changed
+
+- A selected layer resizes and rotates where Figma's does: every edge resizes along its whole length within 7.5 px outside it and up to a tenth of the side inside it, corners within 7.5 px, and the area outside a corner within 16 px rotates; a frame's name takes a press before rotation but not before resizing. Layers under 24 px keep these zones outside them, and a layer under 10 px on both sides has none, taking presses within 16 px across its centre instead. A selection draws Figma's four corner handles, without the edge midpoints, and none on such a small layer.
+
## 0.16.0-beta.1 — 2026-10-11
This is a pre-release: npm packages are published under the `next` tag, and installed apps on the stable release do not update to it. Linux package managers see `0.16.0-beta.1` as newer than `0.16.0`, so `.deb` and `.rpm` users should remove the beta before installing the final 0.16.0.
diff --git a/packages/core/src/canvas/overlays/selection.ts b/packages/core/src/canvas/overlays/selection.ts
index 6919bd6b2..7112ac7a6 100644
--- a/packages/core/src/canvas/overlays/selection.ts
+++ b/packages/core/src/canvas/overlays/selection.ts
@@ -16,6 +16,7 @@ import {
} from '#core/constants'
import {
createSceneGeometry,
+ hasTransformHandles,
viewportMatrix,
selectionPath,
rotationHandleLayout,
@@ -286,6 +287,7 @@ function drawTextPathSelection(
)
}
+/** Figma's corner handles and our rotation stalk; a layer too small for handles shows none. */
function drawBoundsHandles(
r: SkiaRenderer,
canvas: Canvas,
@@ -295,18 +297,13 @@ function drawBoundsHandles(
maxY: number,
stalk: RotationHandleLayout
): void {
+ if (!hasTransformHandles((maxX - minX) * r.zoom, (maxY - minY) * r.zoom)) return
r.drawHandle(canvas, minX, minY)
r.drawHandle(canvas, maxX, minY)
r.drawHandle(canvas, minX, maxY)
r.drawHandle(canvas, maxX, maxY)
- const midX = (minX + maxX) / 2
- const midY = (minY + maxY) / 2
canvas.drawLine(stalk.edge.x, stalk.edge.y, stalk.handle.x, stalk.handle.y, r.selectionPaint)
r.drawHandle(canvas, stalk.handle.x, stalk.handle.y)
- r.drawHandle(canvas, midX, minY)
- r.drawHandle(canvas, midX, maxY)
- r.drawHandle(canvas, minX, midY)
- r.drawHandle(canvas, maxX, midY)
}
function drawSelectionRect(
@@ -484,17 +481,13 @@ function drawBoundsHandlesScreenSpace(
maxX: number,
maxY: number
): void {
+ if (!hasTransformHandles(maxX - minX, maxY - minY)) return
drawHandleScreenSpace(r, canvas, minX, minY)
drawHandleScreenSpace(r, canvas, maxX, minY)
drawHandleScreenSpace(r, canvas, minX, maxY)
drawHandleScreenSpace(r, canvas, maxX, maxY)
const midX = (minX + maxX) / 2
- const midY = (minY + maxY) / 2
const rotationHandleY = minY - ROTATION_HANDLE_DISTANCE
canvas.drawLine(midX, minY, midX, rotationHandleY, r.selectionPaint)
drawHandleScreenSpace(r, canvas, midX, rotationHandleY)
- drawHandleScreenSpace(r, canvas, midX, minY)
- drawHandleScreenSpace(r, canvas, midX, maxY)
- drawHandleScreenSpace(r, canvas, minX, midY)
- drawHandleScreenSpace(r, canvas, maxX, midY)
}
diff --git a/packages/core/src/constants.ts b/packages/core/src/constants.ts
index 841d2823d..72768180a 100644
--- a/packages/core/src/constants.ts
+++ b/packages/core/src/constants.ts
@@ -565,7 +565,6 @@ export const ZOOM_SCALE_MAX = 1.25
export const PEN_CLOSE_THRESHOLD = 8
export const ROTATION_SNAP_DEGREES = 15
-export const CORNER_ROTATE_ZONE = 16
export const HANDLE_HIT_RADIUS = 6
export const ROTATION_HANDLE_DISTANCE = 24
export const DEFAULT_TEXT_WIDTH = 200
diff --git a/packages/core/src/geometry/index.ts b/packages/core/src/geometry/index.ts
index fd2995175..16a8b26ca 100644
--- a/packages/core/src/geometry/index.ts
+++ b/packages/core/src/geometry/index.ts
@@ -40,5 +40,12 @@ export type {
export { createSceneGeometry, nodeOrientationMatrix, projectedNode, viewportMatrix } from './scene'
export type { SceneGeometry } from './scene'
export { selectionPath, selectionHandleRect, rotationHandleLayout } from './selection'
+export {
+ TRANSFORM_ZONE,
+ hasTransformHandles,
+ pressesTinyLayer,
+ transformZoneAt
+} from './transform-zones'
+export type { CornerPosition, HandlePosition, TransformZone } from './transform-zones'
export type { RotationHandleLayout } from './selection'
export type { RotationPreview, ViewportTransform } from './types'
diff --git a/packages/core/src/geometry/transform-zones.ts b/packages/core/src/geometry/transform-zones.ts
new file mode 100644
index 000000000..6658dbd60
--- /dev/null
+++ b/packages/core/src/geometry/transform-zones.ts
@@ -0,0 +1,160 @@
+import { minBy } from 'es-toolkit'
+
+import type { Vector } from '@open-pencil/scene-graph'
+import type { Rect } from '@open-pencil/scene-graph/primitives'
+
+/**
+ * Where a selected layer takes the pointer for resizing and rotating, as Figma desktop measures
+ * it, in screen pixels in the layer's own frame. Every edge resizes along a band that reaches
+ * `resizeReach` outside it and short of a tenth of the side inside it; a corner resizes within
+ * `resizeReach` of it, and rotates outside the layer within `rotateReach` of it.
+ */
+export const TRANSFORM_ZONE = {
+ /** How far outside an edge, and around a corner, the pointer resizes. */
+ resizeReach: 7.5,
+ /** The share of a side its edge bands reach inside the layer, short of it and of `innerMax`. */
+ innerShare: 0.1,
+ innerMax: 8,
+ /** A layer with a side shorter than this keeps its bands and corners outside it. */
+ innerMinSide: 24,
+ /** A layer with both sides shorter than this takes no resize or rotation. */
+ minSide: 10,
+ /** Such a layer, selected, takes a press within a span this long centred on it, either way. */
+ tinyHitSpan: 16,
+ /** How far from a corner, outside the layer, the pointer rotates. */
+ rotateReach: 16
+} as const
+
+export type HandlePosition = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w'
+
+export type CornerPosition = 'nw' | 'ne' | 'se' | 'sw'
+
+export type TransformZone =
+ | { kind: 'resize'; handle: HandlePosition }
+ | { kind: 'rotate'; corner: CornerPosition }
+
+type Edge = 'w' | 'e' | 'n' | 's'
+
+interface Corner {
+ handle: CornerPosition
+ /** The vertical and the horizontal edge that meet at the corner. */
+ x: Edge
+ y: Edge
+}
+
+const CORNERS: readonly Corner[] = [
+ { handle: 'nw', x: 'w', y: 'n' },
+ { handle: 'ne', x: 'e', y: 'n' },
+ { handle: 'se', x: 'e', y: 's' },
+ { handle: 'sw', x: 'w', y: 's' }
+]
+
+/** Vertical edges first: at a small layer's corner, Figma resizes its width. */
+const EDGES: readonly Edge[] = ['w', 'e', 'n', 's']
+
+/** A point against a selected layer, in screen pixels in the layer's own frame. */
+interface ZoneFrame {
+ width: number
+ height: number
+ x: number
+ y: number
+ /** How far outside each edge the point lies; negative inside. */
+ outside: Record<Edge, number>
+ /** A side under `innerMinSide` keeps every band outside the layer. */
+ small: boolean
+}
+
+/** How far an edge band reaches inside the layer. */
+function innerReach(frame: ZoneFrame, edge: Edge) {
+ if (frame.small) return 0
+ const side = edge === 'w' || edge === 'e' ? frame.width : frame.height
+ return Math.min(TRANSFORM_ZONE.innerMax, side * TRANSFORM_ZONE.innerShare)
+}
+
+function inBand(frame: ZoneFrame, edge: Edge) {
+ const vertical = edge === 'w' || edge === 'e'
+ const along = vertical ? frame.y : frame.x
+ const across = frame.outside[edge]
+ const limit = innerReach(frame, edge)
+ // A small layer's bands start where the layer ends: its left and top edges are inside it, its
+ // right and bottom ones beyond it. A larger layer's bands stop short of their inner reach.
+ const startsBeyond = edge === 'e' || edge === 's' ? across >= 0 : across > 0
+ return (
+ across <= TRANSFORM_ZONE.resizeReach &&
+ (limit === 0 ? startsBeyond : -across < limit) &&
+ along >= 0 &&
+ along <= (vertical ? frame.height : frame.width)
+ )
+}
+
+function resizesCorner(frame: ZoneFrame, corner: Corner) {
+ const reach = TRANSFORM_ZONE.resizeReach
+ const dx = frame.outside[corner.x]
+ const dy = frame.outside[corner.y]
+ const distance = Math.hypot(dx, dy)
+ // A small layer's corners take the pointer only beyond both of its edges.
+ if (frame.small) return dx > 0 && dy > 0 && distance <= reach
+ return (
+ distance <= reach ||
+ (inBand(frame, corner.x) && Math.abs(dy) <= reach) ||
+ (inBand(frame, corner.y) && Math.abs(dx) <= reach)
+ )
+}
+
+/** The corner nearest a point outside the layer within `rotateReach` of it. */
+function rotatedCorner(frame: ZoneFrame): CornerPosition | null {
+ const { outside } = frame
+ if (outside.w <= 0 && outside.e <= 0 && outside.n <= 0 && outside.s <= 0) return null
+ const distance = (corner: Corner) => Math.hypot(outside[corner.x], outside[corner.y])
+ const nearest = minBy(CORNERS, distance)
+ return nearest && distance(nearest) <= TRANSFORM_ZONE.rotateReach ? nearest.handle : null
+}
+
+/** Whether a layer of this size on screen shows and takes resize and rotation handles. */
+export function hasTransformHandles(width: number, height: number): boolean {
+ return width >= TRANSFORM_ZONE.minSide || height >= TRANSFORM_ZONE.minSide
+}
+
+/**
+ * The zone under a point given in the layer's own frame, with the layer's rect in that frame and
+ * the zoom that maps it to the screen; `null` where the pointer neither resizes nor rotates.
+ */
+export function transformZoneAt(point: Vector, rect: Rect, zoom: number): TransformZone | null {
+ const width = rect.width * zoom
+ const height = rect.height * zoom
+ if (!hasTransformHandles(width, height)) return null
+ const x = (point.x - rect.x) * zoom
+ const y = (point.y - rect.y) * zoom
+ const frame: ZoneFrame = {
+ width,
+ height,
+ x,
+ y,
+ outside: { w: -x, e: x - width, n: -y, s: y - height },
+ small: width < TRANSFORM_ZONE.innerMinSide || height < TRANSFORM_ZONE.innerMinSide
+ }
+ const corner = CORNERS.find((candidate) => resizesCorner(frame, candidate))
+ if (corner) return { kind: 'resize', handle: corner.handle }
+ const edge = EDGES.find((candidate) => inBand(frame, candidate))
+ if (edge) return { kind: 'resize', handle: edge }
+ const rotated = rotatedCorner(frame)
+ return rotated ? { kind: 'rotate', corner: rotated } : null
+}
+
+/**
+ * Whether a selected layer too small for handles takes a press at a point in its own frame, as
+ * Figma widens it: to `tinyHitSpan` across its centre along either axis, within its extent along
+ * the other.
+ */
+export function pressesTinyLayer(point: Vector, rect: Rect, zoom: number): boolean {
+ const width = rect.width * zoom
+ const height = rect.height * zoom
+ if (hasTransformHandles(width, height)) return false
+ const x = (point.x - rect.x) * zoom
+ const y = (point.y - rect.y) * zoom
+ const half = TRANSFORM_ZONE.tinyHitSpan / 2
+ const across = (offset: number, side: number) =>
+ Math.abs(offset - side / 2) <= Math.max(half, side / 2)
+ const within = (offset: number, side: number) => offset >= 0 && offset <= side
+ return (across(x, width) && within(y, height)) || (within(x, width) && across(y, height))
+}
diff --git a/packages/core/tests/geometry/transform-zones.test.ts b/packages/core/tests/geometry/transform-zones.test.ts
new file mode 100644
index 000000000..80a972c33
--- /dev/null
+++ b/packages/core/tests/geometry/transform-zones.test.ts
@@ -0,0 +1,128 @@
+import { describe, expect, test } from 'bun:test'
+
+import { pressesTinyLayer, transformZoneAt } from '@open-pencil/core/geometry'
+
+/** The zone at a point given in screen pixels from a layer's top-left corner, as a short name. */
+function zone(width: number, height: number, x: number, y: number, zoom = 1) {
+ const found = transformZoneAt({ x: x / zoom, y: y / zoom }, { x: 0, y: 0, width, height }, zoom)
+ if (!found) return null
+ return found.kind === 'resize' ? found.handle : `rotate ${found.corner}`
+}
+
+// Every case is a drag Figma desktop 126 answered on a frame at a known screen point: a resize
+// from a handle, a rotation, or neither (a move inside the layer, a marquee outside it).
+describe('Figma transform zones', () => {
+ test('a corner resizes within 7.5 px of it, and along its edges near it', () => {
+ const at = (dx: number, dy: number) => zone(240, 160, 240 + dx, 160 + dy)
+ expect(at(5, 5)).toBe('se')
+ expect(at(5.3, 5.3)).toBe('se')
+ expect(at(7.4, 0)).toBe('se')
+ expect(at(0, 7)).toBe('se')
+ expect(at(7, -3)).toBe('se')
+ expect(at(-3, 7)).toBe('se')
+ expect(at(-1, 7)).toBe('se')
+ expect(at(5.5, 5.5)).toBe('rotate se')
+ expect(at(7.6, 0)).toBe('rotate se')
+ })
+
+ test('outside the layer near a corner rotates, up to 16 px from it', () => {
+ const at = (dx: number, dy: number) => zone(240, 160, 240 + dx, 160 + dy)
+ expect(at(10, 10)).toBe('rotate se')
+ expect(at(12, -3)).toBe('rotate se')
+ expect(at(12, -10)).toBe('rotate se')
+ expect(at(-6, 12)).toBe('rotate se')
+ expect(at(12, 12)).toBeNull()
+ expect(at(18, 0)).toBeNull()
+ })
+
+ test('an edge resizes 7.5 px outside it and up to a tenth of the side inside it', () => {
+ expect(zone(240, 160, 246, 120)).toBe('e')
+ expect(zone(240, 160, 234, 120)).toBe('e')
+ expect(zone(240, 160, 248, 120)).toBeNull()
+ expect(zone(240, 160, 232, 120)).toBeNull()
+ expect(zone(48, 200, 48 - 4, 100)).toBe('e')
+ expect(zone(48, 200, 48 - 5, 100)).toBeNull()
+ expect(zone(24, 200, 24 - 2, 100)).toBe('e')
+ expect(zone(24, 200, 24 - 3, 100)).toBeNull()
+ expect(zone(60, 200, 60 - 5, 100)).toBe('e')
+ expect(zone(60, 200, 60 - 6, 100)).toBeNull()
+ expect(zone(80, 200, 80 - 7.5, 100)).toBe('e')
+ expect(zone(80, 200, 80 - 8, 100)).toBeNull()
+ for (const width of [6, 16, 48]) {
+ expect(zone(width, 200, width + 7, 100)).toBe('e')
+ expect(zone(width, 200, width + 8, 100)).toBeNull()
+ }
+ })
+
+ test('a side under 24 px keeps every band outside the layer', () => {
+ expect(zone(22, 200, 22, 100)).toBe('e')
+ expect(zone(22, 200, 21, 100)).toBeNull()
+ expect(zone(120, 6, 117, 3)).toBeNull()
+ expect(zone(120, 6, 60, 9)).toBe('s')
+ expect(zone(6, 120, 3, 123)).toBe('s')
+ })
+
+ test("a small layer's left and top edges are inside it, its right and bottom ones beyond it", () => {
+ expect(zone(6, 200, 0, 100)).toBeNull()
+ expect(zone(6, 200, 6, 100)).toBe('e')
+ expect(zone(6, 200, -1, 100)).toBe('w')
+ expect(zone(120, 6, 60, 0)).toBeNull()
+ expect(zone(120, 6, 60, 6)).toBe('s')
+ })
+
+ test('a small layer resizes from a corner only beyond both its edges', () => {
+ expect(zone(10, 10, 13, 13)).toBe('se')
+ expect(zone(10, 10, 15, 15)).toBe('se')
+ expect(zone(10, 10, 10, 10)).toBe('e')
+ expect(zone(10, 10, 17, 10)).toBe('e')
+ expect(zone(10, 10, 10, 17)).toBe('s')
+ expect(zone(10, 10, 13, 7)).toBe('e')
+ expect(zone(10, 10, 9, 9)).toBeNull()
+ expect(zone(10, 10, 20, 20)).toBe('rotate se')
+ expect(zone(10, 10, 22, 7)).toBe('rotate se')
+ expect(zone(23, 23, 23, 23)).toBe('e')
+ expect(zone(120, 16, 120, 16)).toBe('e')
+ expect(zone(24, 24, 27, 21)).toBe('se')
+ expect(zone(24, 24, 19, 19)).toBe('se')
+ expect(zone(24, 24, 18, 18)).toBeNull()
+ })
+
+ test('a layer with both sides under 10 px takes no resize or rotation', () => {
+ for (const [width, height] of [
+ [9, 9],
+ [8, 6],
+ [6, 8]
+ ]) {
+ expect(zone(width, height, width + 3, height / 2)).toBeNull()
+ expect(zone(width, height, width + 10, height + 10)).toBeNull()
+ }
+ expect(zone(6, 10, 9, 5)).toBe('e')
+ expect(zone(10, 6, 14, 10)).toBe('se')
+ })
+
+ test('the zones keep their screen size at any zoom', () => {
+ const at = (dx: number, dy: number) => zone(240, 160, 480 + dx, 320 + dy, 2)
+ expect(at(7.4, 0)).toBe('se')
+ expect(at(7.6, 0)).toBe('rotate se')
+ expect(at(6, -40)).toBe('e')
+ expect(at(-6, -40)).toBe('e')
+ expect(at(8, -40)).toBeNull()
+ expect(at(-8, -40)).toBeNull()
+ expect(at(12, -10)).toBe('rotate se')
+ expect(at(12, 12)).toBeNull()
+ })
+
+ test('a selected layer too small for handles takes presses across a 16 px span', () => {
+ const presses = (width: number, height: number, x: number, y: number) =>
+ pressesTinyLayer({ x, y }, { x: 0, y: 0, width, height }, 1)
+ expect(presses(6, 6, 11, 3)).toBe(true)
+ expect(presses(6, 6, 12, 3)).toBe(false)
+ expect(presses(9, 9, 12, 4.5)).toBe(true)
+ expect(presses(9, 9, 13, 4.5)).toBe(false)
+ expect(presses(2, 2, 8, 1)).toBe(true)
+ expect(presses(2, 2, 6, 6)).toBe(false)
+ expect(presses(6, 6, 10, 10)).toBe(false)
+ expect(presses(6, 6, 3, -5)).toBe(true)
+ expect(presses(6, 30, 11, 15)).toBe(false)
+ })
+})
diff --git a/packages/vue/src/shared/input/geometry.ts b/packages/vue/src/shared/input/geometry.ts
index b05b65ac7..59a7a9a86 100644
--- a/packages/vue/src/shared/input/geometry.ts
+++ b/packages/vue/src/shared/input/geometry.ts
@@ -1,18 +1,22 @@
-import { CORNER_ROTATE_ZONE, HANDLE_HIT_RADIUS } from '@open-pencil/core/constants'
+import { HANDLE_HIT_RADIUS } from '@open-pencil/core/constants'
import type { Editor } from '@open-pencil/core/editor'
import {
createSceneGeometry,
selectionHandleRect,
+ hasTransformHandles,
rotationHandleLayout,
+ transformZoneAt,
+ type CornerPosition,
+ type HandlePosition,
type SceneGeometry,
- type RotationPreview
+ type RotationPreview,
+ type TransformZone
} from '@open-pencil/core/geometry'
import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
import type { Vector } from '@open-pencil/scene-graph/primitives'
import resizeCursorSVG from '#vue/shared/assets/resize-cursor.svg?raw'
import rotateCursorSVG from '#vue/shared/assets/rotate-cursor.svg?raw'
-import type { CornerPosition, HandlePosition } from '#vue/shared/input/types'
export function getPointerCoords(e: MouseEvent, canvas: HTMLCanvasElement | null, editor: Editor) {
if (!canvas) return { sx: 0, sy: 0, cx: 0, cy: 0 }
@@ -162,6 +166,18 @@ function getCursorAngleFromHandle(
return (angle + 360) % 360
}
+/** The resize or rotation zone of a selected layer under a canvas point, in its own frame. */
+function transformZoneOf(
+ cx: number,
+ cy: number,
+ node: SceneNode,
+ geometry: SceneGeometry,
+ zoom: number
+): TransformZone | null {
+ const pointer = geometry.toLocal(node, { x: cx, y: cy })
+ return pointer ? transformZoneAt(pointer, selectionHandleRect(node), zoom) : null
+}
+
export function getHitHandleByMatrix(
cx: number,
cy: number,
@@ -174,27 +190,11 @@ export function getHitHandleByMatrix(
rotation: number
} | null {
const geometry = createSceneGeometry(graph, preview)
- const handles = geometry.handles(node, selectionHandleRect(node))
-
- const CORNER_R = HANDLE_HIT_RADIUS / zoom
- for (const [key, p] of Object.entries(handles)) {
- const handleKey = key as HandlePosition
-
- const dx = cx - p.x
- const dy = cy - p.y
-
- if (dx * dx + dy * dy <= CORNER_R * CORNER_R) {
- const angle = getCursorAngleFromHandle(handleKey, node, geometry)
-
- return {
- handle: handleKey,
- rotation: angle
- }
- }
- }
-
- return null
+ const zone = transformZoneOf(cx, cy, node, geometry, zoom)
+ if (zone?.kind !== 'resize') return null
+ return { handle: zone.handle, rotation: getCursorAngleFromHandle(zone.handle, node, geometry) }
}
+
export function hitTestTopRotationHandleByMatrix(
cx: number,
cy: number,
@@ -203,6 +203,8 @@ export function hitTestTopRotationHandleByMatrix(
zoom: number = 1,
preview?: RotationPreview | null
): boolean {
+ const rect = selectionHandleRect(node)
+ if (!hasTransformHandles(rect.width * zoom, rect.height * zoom)) return false
const geometry = createSceneGeometry(graph, preview)
const handle = geometry.toWorld(node, rotationHandleLayout(node, geometry, zoom).handle)
const radius = HANDLE_HIT_RADIUS / zoom
@@ -219,47 +221,8 @@ export function hitTestCornerRotationByMatrix(
zoom: number = 1,
preview?: RotationPreview | null
): CornerPosition | null {
- const geometry = createSceneGeometry(graph, preview)
- const handles = geometry.handles(node, selectionHandleRect(node))
- const pointer = geometry.toLocal(node, { x: cx, y: cy })
- if (!pointer) return null
-
- const HANDLE_R = HANDLE_HIT_RADIUS / zoom
- const ROTATE_R = CORNER_ROTATE_ZONE / zoom
-
- const corners: Array<{ key: CornerPosition; p: Vector }> = [
- { key: 'nw', p: handles.nw },
- { key: 'ne', p: handles.ne },
- { key: 'se', p: handles.se },
- { key: 'sw', p: handles.sw }
- ]
-
- for (const { key, p } of corners) {
- const local = geometry.toLocal(node, p)
- if (!local) continue
- const dx = pointer.x - local.x
- const dy = pointer.y - local.y
- const d = Math.hypot(dx, dy)
-
- if (d > HANDLE_R && d <= ROTATE_R) {
- switch (key) {
- case 'nw':
- if (dx < 0 && dy < 0) return key
- break
- case 'ne':
- if (dx > 0 && dy < 0) return key
- break
- case 'se':
- if (dx > 0 && dy > 0) return key
- break
- case 'sw':
- if (dx < 0 && dy > 0) return key
- break
- }
- }
- }
-
- return null
+ const zone = transformZoneOf(cx, cy, node, createSceneGeometry(graph, preview), zoom)
+ return zone?.kind === 'rotate' ? zone.corner : null
}
const rotationCursorCache = new Map<number, string>()
diff --git a/packages/vue/src/shared/input/resize/rect.ts b/packages/vue/src/shared/input/resize/rect.ts
index 7c812d6b3..dc4b61782 100644
--- a/packages/vue/src/shared/input/resize/rect.ts
+++ b/packages/vue/src/shared/input/resize/rect.ts
@@ -1,7 +1,6 @@
+import type { HandlePosition } from '@open-pencil/core/geometry'
import type { Rect } from '@open-pencil/scene-graph/primitives'
-import type { HandlePosition } from '#vue/shared/input/types'
-
/** `value` at least `min` long, keeping the direction it was dragged in. */
function atLeast(value: number, min: number): number {
return Math.sign(value || 1) * Math.max(Math.abs(value), min)
diff --git a/packages/vue/src/shared/input/resize/snap.ts b/packages/vue/src/shared/input/resize/snap.ts
index 21dabe726..b4944aa1c 100644
--- a/packages/vue/src/shared/input/resize/snap.ts
+++ b/packages/vue/src/shared/input/resize/snap.ts
@@ -1,4 +1,5 @@
import type { Editor } from '@open-pencil/core/editor'
+import type { HandlePosition } from '@open-pencil/core/geometry'
import type { SceneNode } from '@open-pencil/scene-graph'
import { getAxisAlignedWorldBounds, getWorldMatrix } from '@open-pencil/scene-graph/coordinate'
import type { Rect } from '@open-pencil/scene-graph/primitives'
@@ -10,7 +11,7 @@ import {
worldBoundsNode,
worldDeltaToParentLocal
} from '#vue/shared/input/snap'
-import type { DragResize, HandlePosition } from '#vue/shared/input/types'
+import type { DragResize } from '#vue/shared/input/types'
function movesLeft(handle: HandlePosition): boolean {
return handle.includes('w')
diff --git a/packages/vue/src/shared/input/select.ts b/packages/vue/src/shared/input/select.ts
index 727373347..aeb572c39 100644
--- a/packages/vue/src/shared/input/select.ts
+++ b/packages/vue/src/shared/input/select.ts
@@ -1,6 +1,6 @@
import { getNodeEditState, handleNodeEditDown } from '#vue/shared/input/vector'
export { resolveHit } from '#vue/shared/input/select/hit'
-import { resolveHit } from '#vue/shared/input/select/hit'
+import { hitTestLabel, resolveHit, tinySelectionAt } from '#vue/shared/input/select/hit'
export { updateHoverCursor } from '#vue/shared/input/select/hover'
import { editedGradient, type Editor } from '@open-pencil/core/editor'
import type { SceneNode } from '@open-pencil/scene-graph'
@@ -32,8 +32,8 @@ function startMarquee(cx: number, cy: number, editor: Editor, setDrag: (d: DragS
}
/**
- * Starts dragging a gradient handle, or else the selection's corner radius, rotation, or resize
- * handles.
+ * Starts dragging a gradient handle, or else the selection's corner radius, resize, or rotation
+ * handles. A layer's label takes the press before rotation but after resizing, as in Figma.
*/
function tryStartHandleDrag(
cx: number,
@@ -42,6 +42,7 @@ function tryStartHandleDrag(
sy: number,
altKey: boolean,
editor: Editor,
+ fns: HitTestFns,
tryStartRotation: (cx: number, cy: number) => boolean,
setDrag: (d: DragState) => void
): boolean {
@@ -49,10 +50,12 @@ function tryStartHandleDrag(
// An open gradient's handles replace the layer's selection handles, which then do not respond.
if (editedGradient(editor.graph, editor.state.gradientEdit)) return false
if (tryStartShapeHandleDrag(editor, sx, sy, altKey, setDrag)) return true
- if (tryStartRotation(cx, cy)) return true
const resizeDrag = tryStartResize(cx, cy, editor)
- if (resizeDrag) setDrag(resizeDrag)
- return resizeDrag !== null
+ if (resizeDrag) {
+ setDrag(resizeDrag)
+ return true
+ }
+ return !hitTestLabel(cx, cy, fns) && tryStartRotation(cx, cy)
}
export function handleSelectDown(
@@ -77,9 +80,10 @@ export function handleSelectDown(
if (editor.state.editingTextId) editor.commitTextEdit()
- if (tryStartHandleDrag(cx, cy, sx, sy, e.altKey, editor, tryStartRotation, setDrag)) return
+ if (tryStartHandleDrag(cx, cy, sx, sy, e.altKey, editor, fns, tryStartRotation, setDrag)) return
- const hit = resolveHit(cx, cy, editor, fns, e.metaKey || e.ctrlKey)
+ const hit =
+ tinySelectionAt(cx, cy, editor) ?? resolveHit(cx, cy, editor, fns, e.metaKey || e.ctrlKey)
if (!hit) {
if (!editor.state.enteredContainerId) startMarquee(cx, cy, editor, setDrag)
return
diff --git a/packages/vue/src/shared/input/select/hit.ts b/packages/vue/src/shared/input/select/hit.ts
index 2c86d5bd2..739086774 100644
--- a/packages/vue/src/shared/input/select/hit.ts
+++ b/packages/vue/src/shared/input/select/hit.ts
@@ -1,8 +1,38 @@
import type { Editor } from '@open-pencil/core/editor'
+import {
+ createSceneGeometry,
+ pressesTinyLayer,
+ selectionHandleRect
+} from '@open-pencil/core/geometry'
import type { SceneNode } from '@open-pencil/scene-graph'
import type { HitTestFns } from '#vue/shared/input/select'
+/** The layer whose label is under a point; labels are drawn frames first, so the topmost is first. */
+export function hitTestLabel(
+ cx: number,
+ cy: number,
+ fns: Pick<HitTestFns, 'hitTestComponentLabel' | 'hitTestSectionTitle' | 'hitTestFrameTitle'>
+): SceneNode | null {
+ return (
+ fns.hitTestComponentLabel(cx, cy) ??
+ fns.hitTestSectionTitle(cx, cy) ??
+ fns.hitTestFrameTitle(cx, cy)
+ )
+}
+
+/** A selected layer too small for handles that takes a press near it, as Figma widens it. */
+export function tinySelectionAt(cx: number, cy: number, editor: Editor): SceneNode | null {
+ const geometry = createSceneGeometry(editor.graph, editor.state.rotationPreview)
+ const zoom = editor.renderer?.zoom ?? 1
+ for (const id of editor.state.selectedIds) {
+ const node = editor.graph.getNode(id)
+ const point = node && geometry.toLocal(node, { x: cx, y: cy })
+ if (node && point && pressesTinyLayer(point, selectionHandleRect(node), zoom)) return node
+ }
+ return null
+}
+
/** The layer a press selects; `deep` (Cmd or Ctrl held) reaches the deepest layer, as in Figma. */
export function resolveHit(
cx: number,
@@ -11,11 +41,7 @@ export function resolveHit(
fns: HitTestFns,
deep = false
): SceneNode | null {
- // Labels are drawn frames first, then sections, then components, so the topmost is tested first.
- const titleHit =
- fns.hitTestComponentLabel(cx, cy) ??
- fns.hitTestSectionTitle(cx, cy) ??
- fns.hitTestFrameTitle(cx, cy)
+ const titleHit = hitTestLabel(cx, cy, fns)
if (titleHit) return titleHit
const hit = fns.hitTestInScope(cx, cy, deep)
diff --git a/packages/vue/src/shared/input/select/hover.ts b/packages/vue/src/shared/input/select/hover.ts
index 64d90d754..38c531c91 100644
--- a/packages/vue/src/shared/input/select/hover.ts
+++ b/packages/vue/src/shared/input/select/hover.ts
@@ -7,6 +7,7 @@ import {
hitTestCornerRotationByMatrix
} from '#vue/shared/input/geometry'
import type { HitTestFns } from '#vue/shared/input/select'
+import { hitTestLabel } from '#vue/shared/input/select/hit'
import { getNodeEditState } from '#vue/shared/input/vector'
function getResizeCursorForSelection(cx: number, cy: number, editor: Editor): string | null {
@@ -59,10 +60,7 @@ function updateHoveredNode(
) {
const hit = deep
? fns.hitTestInScope(cx, cy, true)
- : (fns.hitTestComponentLabel(cx, cy) ??
- fns.hitTestSectionTitle(cx, cy) ??
- fns.hitTestFrameTitle(cx, cy) ??
- fns.hitTestInScope(cx, cy, false))
+ : (hitTestLabel(cx, cy, fns) ?? fns.hitTestInScope(cx, cy, false))
const editNodeId = getNodeEditState(editor)?.nodeId
editor.setHoveredNode(
hit && !editor.state.selectedIds.has(hit.id) && hit.id !== editNodeId ? hit.id : null
@@ -84,8 +82,10 @@ export function updateHoverCursor(
return null
}
+ // As a press does: resizing first, then a label, then rotation.
const cursor =
- getResizeCursorForSelection(cx, cy, editor) ?? getRotationCursorForSelection(cx, cy, editor)
+ getResizeCursorForSelection(cx, cy, editor) ??
+ (hitTestLabel(cx, cy, fns) ? null : getRotationCursorForSelection(cx, cy, editor))
updateHoveredNode(cx, cy, editor, fns, deep)
return cursor
}
diff --git a/packages/vue/src/shared/input/types.ts b/packages/vue/src/shared/input/types.ts
index d2f8a34de..356c0d1bd 100644
--- a/packages/vue/src/shared/input/types.ts
+++ b/packages/vue/src/shared/input/types.ts
@@ -1,4 +1,5 @@
import type { MovePlace, Tool } from '@open-pencil/core/editor'
+import type { HandlePosition } from '@open-pencil/core/geometry'
import type {
DerivedTextGlyph,
GeometryPath,
@@ -14,10 +15,6 @@ import type { ResizeSnapshot } from '@open-pencil/scene-graph/resize'
import type { FlowDrag } from '#vue/shared/input/flow-reorder'
import type { LayerSizing } from '#vue/shared/input/resize/sizing'
-export type HandlePosition = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w'
-
-export type CornerPosition = 'nw' | 'ne' | 'se' | 'sw'
-
export interface DragDraw {
type: 'draw'
/** Start point in the parent's axes. */
diff --git a/packages/vue/tests/shared/input/select/hover.test.ts b/packages/vue/tests/shared/input/select/hover.test.ts
new file mode 100644
index 000000000..f23545a4f
--- /dev/null
+++ b/packages/vue/tests/shared/input/select/hover.test.ts
@@ -0,0 +1,48 @@
+import { afterEach, expect, test } from 'bun:test'
+
+import { createEditor, type Editor } from '@open-pencil/core/editor'
+import type { SceneNode } from '@open-pencil/scene-graph'
+
+import {
+ cornerRotationCursor,
+ getHitHandleByMatrix,
+ buildResizeCursor
+} from '#vue/shared/input/geometry'
+import { updateHoverCursor } from '#vue/shared/input/select/hover'
+
+let editor: Editor
+
+afterEach(() => editor.dispose())
+
+/** A selected 240×160 frame at the origin, viewed at 100%, with its label under every point. */
+function selectedFrame(labelled: boolean) {
+ editor = createEditor()
+ const frame = editor.graph.createNode('FRAME', editor.state.currentPageId, {
+ width: 240,
+ height: 160
+ })
+ editor.select([frame.id])
+ const fns = {
+ hitTestInScope: () => null,
+ hitTestFrameTitle: (): SceneNode | null => (labelled ? frame : null),
+ hitTestSectionTitle: () => null,
+ hitTestComponentLabel: () => null
+ }
+ return { frame, cursorAt: (x: number, y: number) => updateHoverCursor(x, y, editor, fns) }
+}
+
+test('outside a corner rotates, unless a label is there, as in Figma', () => {
+ const plain = selectedFrame(false)
+ expect(plain.cursorAt(-9, -6)).toBe(cornerRotationCursor('nw', plain.frame, editor.graph))
+ editor.dispose()
+ const labelled = selectedFrame(true)
+ expect(labelled.cursorAt(-9, -6)).toBeNull()
+})
+
+test('a label does not take the press from a resize band', () => {
+ const { frame, cursorAt } = selectedFrame(true)
+ const hit = getHitHandleByMatrix(-3, -3, frame, editor.graph)
+ expect(hit?.handle).toBe('nw')
+ expect(cursorAt(-3, -3)).toBe(buildResizeCursor(hit?.rotation ?? 0))
+ expect(getHitHandleByMatrix(120, -5, frame, editor.graph)?.handle).toBe('n')
+})
diff --git a/src/constants.ts b/src/constants.ts
index a2c89c2cd..1a2d0f4e5 100644
--- a/src/constants.ts
+++ b/src/constants.ts
@@ -129,10 +129,8 @@ export const ACTION_TOAST_DURATION = 800
export const DRAG_DEAD_ZONE = 4
export const PEN_CLOSE_THRESHOLD = 8
export const ROTATION_SNAP_DEGREES = 15
-export const CORNER_ROTATE_ZONE = 16
export const DEFAULT_TEXT_WIDTH = 200
export const DEFAULT_TEXT_HEIGHT = 24
-export const HANDLE_HIT_RADIUS = 6
export const ACP_PERMISSION_TIMEOUT_MS = 60_000
diff --git a/tests/e2e/canvas/component-overlays.spec.ts-snapshots/component-descendant-outlines-openpencil-darwin.png b/tests/e2e/canvas/component-overlays.spec.ts-snapshots/component-descendant-outlines-openpencil-darwin.png
index 256c4e674..c4d990a09 100644
Binary files a/tests/e2e/canvas/component-overlays.spec.ts-snapshots/component-descendant-outlines-openpencil-darwin.png and b/tests/e2e/canvas/component-overlays.spec.ts-snapshots/component-descendant-outlines-openpencil-darwin.png differ
diff --git a/tests/e2e/canvas/frame-overlays.spec.ts b/tests/e2e/canvas/frame-overlays.spec.ts
index bf6f7ed3d..38268b002 100644
--- a/tests/e2e/canvas/frame-overlays.spec.ts
+++ b/tests/e2e/canvas/frame-overlays.spec.ts
@@ -1,6 +1,6 @@
import { writeFile } from 'node:fs/promises'
-import { CORNER_ROTATE_ZONE, HANDLE_HIT_RADIUS } from '@open-pencil/core/constants'
+import { TRANSFORM_ZONE } from '@open-pencil/core/geometry'
import { expect, test, useEditorSetupWithClear } from '#tests/e2e/fixtures'
import { expectDefined } from '#tests/helpers/assert'
@@ -178,7 +178,8 @@ for (const angle of [-32, 32]) {
if (!store) throw new Error('Editor unavailable')
return { zoom: store.state.zoom, panX: store.state.panX, panY: store.state.panY }
})
- const cornerOffset = (HANDLE_HIT_RADIUS + CORNER_ROTATE_ZONE) / (2 * Math.SQRT2)
+ const cornerOffset =
+ (TRANSFORM_ZONE.resizeReach + TRANSFORM_ZONE.rotateReach) / (2 * Math.SQRT2)
const centerX = bounds.x + viewport.panX + 390 * viewport.zoom
const centerY = bounds.y + viewport.panY + 310 * viewport.zoom
const dx = -150 * viewport.zoom - cornerOffset
diff --git a/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/frame-held-rotation--32-openpencil-darwin.png b/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/frame-held-rotation--32-openpencil-darwin.png
index 91d43f952..07b56e71d 100644
Binary files a/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/frame-held-rotation--32-openpencil-darwin.png and b/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/frame-held-rotation--32-openpencil-darwin.png differ
diff --git a/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/frame-held-rotation-32-openpencil-darwin.png b/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/frame-held-rotation-32-openpencil-darwin.png
index 9d6722f55..c7d4ed62e 100644
Binary files a/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/frame-held-rotation-32-openpencil-darwin.png and b/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/frame-held-rotation-32-openpencil-darwin.png differ
diff --git a/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/nested-frame-rotation-preview-openpencil-darwin.png b/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/nested-frame-rotation-preview-openpencil-darwin.png
index 8b11d222e..1f07966e3 100644
Binary files a/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/nested-frame-rotation-preview-openpencil-darwin.png and b/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/nested-frame-rotation-preview-openpencil-darwin.png differ
diff --git a/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/rotated-frame-child-hover-highlight-openpencil-darwin.png b/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/rotated-frame-child-hover-highlight-openpencil-darwin.png
index b70ec5e24..1f17d3d29 100644
Binary files a/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/rotated-frame-child-hover-highlight-openpencil-darwin.png and b/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/rotated-frame-child-hover-highlight-openpencil-darwin.png differ
diff --git a/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/rotated-frame-selection-labels-openpencil-darwin.png b/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/rotated-frame-selection-labels-openpencil-darwin.png
index 4da98cb97..9cb4c7604 100644
Binary files a/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/rotated-frame-selection-labels-openpencil-darwin.png and b/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/rotated-frame-selection-labels-openpencil-darwin.png differ
diff --git a/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/rotated-frame-selection-labels-preview-openpencil-darwin.png b/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/rotated-frame-selection-labels-preview-openpencil-darwin.png
index b70ec5e24..1f17d3d29 100644
Binary files a/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/rotated-frame-selection-labels-preview-openpencil-darwin.png and b/tests/e2e/canvas/frame-overlays.spec.ts-snapshots/rotated-frame-selection-labels-preview-openpencil-darwin.png differ
diff --git a/tests/e2e/canvas/label-anatomy.spec.ts-snapshots/readable-frame--145-openpencil-darwin.png b/tests/e2e/canvas/label-anatomy.spec.ts-snapshots/readable-frame--145-openpencil-darwin.png
index e917ddd9a..d5399f464 100644
Binary files a/tests/e2e/canvas/label-anatomy.spec.ts-snapshots/readable-frame--145-openpencil-darwin.png and b/tests/e2e/canvas/label-anatomy.spec.ts-snapshots/readable-frame--145-openpencil-darwin.png differ
diff --git a/tests/e2e/canvas/label-anatomy.spec.ts-snapshots/readable-frame--40-openpencil-darwin.png b/tests/e2e/canvas/label-anatomy.spec.ts-snapshots/readable-frame--40-openpencil-darwin.png
index 36d497abb..685e01d8a 100644
Binary files a/tests/e2e/canvas/label-anatomy.spec.ts-snapshots/readable-frame--40-openpencil-darwin.png and b/tests/e2e/canvas/label-anatomy.spec.ts-snapshots/readable-frame--40-openpencil-darwin.png differ
diff --git a/tests/e2e/canvas/label-anatomy.spec.ts-snapshots/readable-frame-50-openpencil-darwin.png b/tests/e2e/canvas/label-anatomy.spec.ts-snapshots/readable-frame-50-openpencil-darwin.png
index e550e74a4..9db963691 100644
Binary files a/tests/e2e/canvas/label-anatomy.spec.ts-snapshots/readable-frame-50-openpencil-darwin.png and b/tests/e2e/canvas/label-anatomy.spec.ts-snapshots/readable-frame-50-openpencil-darwin.png differ
diff --git a/tests/e2e/canvas/layout-outlines.spec.ts-snapshots/layout-outlines-moving-child-openpencil-darwin.png b/tests/e2e/canvas/layout-outlines.spec.ts-snapshots/layout-outlines-moving-child-openpencil-darwin.png
index d0fbe0fe1..a8dc43cfb 100644
Binary files a/tests/e2e/canvas/layout-outlines.spec.ts-snapshots/layout-outlines-moving-child-openpencil-darwin.png and b/tests/e2e/canvas/layout-outlines.spec.ts-snapshots/layout-outlines-moving-child-openpencil-darwin.png differ
diff --git a/tests/e2e/canvas/layout-outlines.spec.ts-snapshots/layout-outlines-selected-child-openpencil-darwin.png b/tests/e2e/canvas/layout-outlines.spec.ts-snapshots/layout-outlines-selected-child-openpencil-darwin.png
index e99676fc5..692fbf6c0 100644
Binary files a/tests/e2e/canvas/layout-outlines.spec.ts-snapshots/layout-outlines-selected-child-openpencil-darwin.png and b/tests/e2e/canvas/layout-outlines.spec.ts-snapshots/layout-outlines-selected-child-openpencil-darwin.png differ
diff --git a/tests/e2e/canvas/nested-transform-interaction.spec.ts-snapshots/nested-transform-false-false-held-openpencil-darwin.png b/tests/e2e/canvas/nested-transform-interaction.spec.ts-snapshots/nested-transform-false-false-held-openpencil-darwin.png
index 8546a4d2c..1eeb8ef61 100644
Binary files a/tests/e2e/canvas/nested-transform-interaction.spec.ts-snapshots/nested-transform-false-false-held-openpencil-darwin.png and b/tests/e2e/canvas/nested-transform-interaction.spec.ts-snapshots/nested-transform-false-false-held-openpencil-darwin.png differ
diff --git a/tests/e2e/canvas/nested-transform-interaction.spec.ts-snapshots/nested-transform-false-true-held-openpencil-darwin.png b/tests/e2e/canvas/nested-transform-interaction.spec.ts-snapshots/nested-transform-false-true-held-openpencil-darwin.png
index 5232309b0..6d50913d5 100644
Binary files a/tests/e2e/canvas/nested-transform-interaction.spec.ts-snapshots/nested-transform-false-true-held-openpencil-darwin.png and b/tests/e2e/canvas/nested-transform-interaction.spec.ts-snapshots/nested-transform-false-true-held-openpencil-darwin.png differ
diff --git a/tests/e2e/canvas/nested-transform-interaction.spec.ts-snapshots/nested-transform-true-false-held-openpencil-darwin.png b/tests/e2e/canvas/nested-transform-interaction.spec.ts-snapshots/nested-transform-true-false-held-openpencil-darwin.png
index 1d9405423..03255a659 100644
Binary files a/tests/e2e/canvas/nested-transform-interaction.spec.ts-snapshots/nested-transform-true-false-held-openpencil-darwin.png and b/tests/e2e/canvas/nested-transform-interaction.spec.ts-snapshots/nested-transform-true-false-held-openpencil-darwin.png differ
diff --git a/tests/e2e/canvas/nested-transform-interaction.spec.ts-snapshots/nested-transform-true-true-held-openpencil-darwin.png b/tests/e2e/canvas/nested-transform-interaction.spec.ts-snapshots/nested-transform-true-true-held-openpencil-darwin.png
index f038c4988..df35f35c3 100644
Binary files a/tests/e2e/canvas/nested-transform-interaction.spec.ts-snapshots/nested-transform-true-true-held-openpencil-darwin.png and b/tests/e2e/canvas/nested-transform-interaction.spec.ts-snapshots/nested-transform-true-true-held-openpencil-darwin.png differ
diff --git a/tests/e2e/canvas/slot-overlays.spec.ts-snapshots/slot-frame-selected-openpencil-darwin.png b/tests/e2e/canvas/slot-overlays.spec.ts-snapshots/slot-frame-selected-openpencil-darwin.png
index 56f4e982d..7c2dba3cc 100644
Binary files a/tests/e2e/canvas/slot-overlays.spec.ts-snapshots/slot-frame-selected-openpencil-darwin.png and b/tests/e2e/canvas/slot-overlays.spec.ts-snapshots/slot-frame-selected-openpencil-darwin.png differ
diff --git a/tests/e2e/canvas/slot-overlays.spec.ts-snapshots/slot-outlines-instance-selected-openpencil-darwin.png b/tests/e2e/canvas/slot-overlays.spec.ts-snapshots/slot-outlines-instance-selected-openpencil-darwin.png
index 71764e6d0..43fd50ded 100644
Binary files a/tests/e2e/canvas/slot-overlays.spec.ts-snapshots/slot-outlines-instance-selected-openpencil-darwin.png and b/tests/e2e/canvas/slot-overlays.spec.ts-snapshots/slot-outlines-instance-selected-openpencil-darwin.png differ
diff --git a/tests/engine/vue/input/geometry.test.ts b/tests/engine/vue/input/geometry.test.ts
index 2de4f549f..e223c4649 100644
--- a/tests/engine/vue/input/geometry.test.ts
+++ b/tests/engine/vue/input/geometry.test.ts
@@ -43,6 +43,14 @@ for (const flipX of [false, true]) {
expect(
hitTestTopRotationHandleByMatrix(handles.n.x, handles.n.y, frame, editor.graph, zoom)
).toBe(false)
+ // An edge resizes along its length, just outside it as on screen.
+ const band = geometry.toWorld(frame, {
+ x: frame.width + 3 / zoom,
+ y: frame.height / 2 + 10 / zoom
+ })
+ expect<string | undefined>(
+ getHitHandleByMatrix(band.x, band.y, frame, editor.graph, zoom)?.handle
+ ).toBe('e')
const outside = geometry.toWorld(frame, { x: -5, y: -5 })
expect(hitTestCornerRotationByMatrix(outside.x, outside.y, frame, editor.graph, zoom)).toBe(
'nw'