test: import geometry helpers from scene graph package

This commit is contained in:
Danila Poyarkov 2026-06-11 23:26:45 +03:00
parent 3a5b6a5c37
commit 5487f659da
5 changed files with 7 additions and 9 deletions

View file

@ -1,6 +1,9 @@
export * from './images'
export * from './snap'
export * from './export-scale'
export * from './geometry'
export { default as TransformMatrix } from './matrix'
export type { Mat3 } from './matrix'
export { UndoManager, type UndoEntry, type UndoManagerOptions } from './undo'
import { omit } from 'es-toolkit/object'
@ -128,7 +131,6 @@ export class SceneGraph {
}
return count
}
// --- Variables ---
addVariable(variable: Variable): void {
Variables.addVariable(this, variable)
}
@ -415,7 +417,6 @@ export class SceneGraph {
const oldParentId = node.parentId
this.absPosCache.clear()
// Convert absolute position
const absPos = this.getAbsolutePosition(nodeId)
const newParentNode = this.nodes.get(newParentId)
const newParentAbs =
@ -423,16 +424,13 @@ export class SceneGraph {
? { x: 0, y: 0 }
: this.getAbsolutePosition(newParentId)
// Remove from old parent
if (oldParent) {
oldParent.childIds = oldParent.childIds.filter((cid) => cid !== nodeId)
}
// Add to new parent
node.parentId = newParentId
newParent.childIds.push(nodeId)
// Adjust position so node stays in same visual place
node.x = absPos.x - newParentAbs.x
node.y = absPos.y - newParentAbs.y

View file

@ -1,6 +1,6 @@
import { describe, test, expect } from 'bun:test'
import { degToRad, radToDeg } from '@open-pencil/core'
import { degToRad, radToDeg } from '@open-pencil/scene-graph'
describe('degToRad / radToDeg', () => {
test('degToRad converts degrees to radians', () => {

View file

@ -1,6 +1,6 @@
import { describe, test, expect } from 'bun:test'
import { computeAbsoluteBounds, computeBounds, type Vector } from '@open-pencil/core'
import { computeAbsoluteBounds, computeBounds, type Vector } from '@open-pencil/scene-graph'
describe('computeBounds', () => {
test('empty iterable returns zero rect', () => {

View file

@ -7,7 +7,7 @@
*/
import { describe, test, expect } from 'bun:test'
import { TransformMatrix } from '@open-pencil/core'
import { TransformMatrix } from '@open-pencil/scene-graph'
import { expectDefined } from '#tests/helpers/assert'

View file

@ -1,6 +1,6 @@
import { describe, test, expect } from 'bun:test'
import { rotatePoint, rotatedBBox, rotatedCorners } from '@open-pencil/core'
import { rotatePoint, rotatedBBox, rotatedCorners } from '@open-pencil/scene-graph'
describe('rotatePoint', () => {
test('no rotation returns same point', () => {