From f2383af8ab2577fd14b7c0b929524dd8bda9ff9d Mon Sep 17 00:00:00 2001 From: Orion Reed Date: Mon, 2 Dec 2024 18:33:07 -0500 Subject: [PATCH] move RotatedDOMRect --- src/common/types.ts | 14 ++++++++++++++ src/folk-shape.ts | 15 +-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/common/types.ts b/src/common/types.ts index 5816552..3eb9c19 100644 --- a/src/common/types.ts +++ b/src/common/types.ts @@ -1 +1,15 @@ export type Point = { x: number; y: number }; + +export type RotatedDOMRect = DOMRect & { + /** in radians */ + rotation: number; + + /** Returns the center point in worldspace coordinates */ + center(): Point; + + /** Returns the four corners in worldspace coordinates, in clockwise order */ + corners(): [Point, Point, Point, Point]; + + /** Returns all the vertices in worldspace coordinates */ + vertices(): Point[]; +}; diff --git a/src/folk-shape.ts b/src/folk-shape.ts index cdee1bb..51dabc8 100644 --- a/src/folk-shape.ts +++ b/src/folk-shape.ts @@ -1,25 +1,12 @@ import { css, html } from './common/tags'; import { ResizeObserverManager } from './common/resize-observer'; -import type { Point } from './common/types'; +import type { Point, RotatedDOMRect } from './common/types'; import { Vector } from './common/Vector'; const resizeObserver = new ResizeObserverManager(); export type Shape = 'rectangle' | 'circle' | 'triangle'; -type RotatedDOMRect = DOMRect & { - /** in radians */ - rotation: number; - - /** Returns the center point in worldspace coordinates */ - center(): Point; - - /** Returns the four corners in worldspace coordinates, in clockwise order */ - corners(): [Point, Point, Point, Point]; - - /** Returns all the vertices in worldspace coordinates */ - vertices(): Point[]; -}; export type MoveEventDetail = { movementX: number; movementY: number }; export class MoveEvent extends CustomEvent {