Line data Source code
1 : import type {
2 : Bounds,
3 : Point2D as Point,
4 : Size2D as Size
5 : } from '@comfyorg/shared-frontend-utils/geometry'
6 :
7 14 : export function toPoint(x: number, y: number): Point {
8 14 : return { x, y }
9 : }
10 :
11 76046 : export function isPointEqual(a: Point, b: Point): boolean {
12 76046 : return a.x === b.x && a.y === b.y
13 : }
14 :
15 0 : export function isBoundsEqual(a: Bounds, b: Bounds): boolean {
16 0 : return (
17 : a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height
18 : )
19 : }
20 :
21 0 : export function isBoundsObject(value: unknown): value is Bounds {
22 0 : if (typeof value !== 'object' || value === null) return false
23 0 : const v = value as Record<string, unknown>
24 0 : return (
25 : typeof v.x === 'number' &&
26 : typeof v.y === 'number' &&
27 : typeof v.width === 'number' &&
28 : typeof v.height === 'number'
29 : )
30 : }
31 :
32 1377 : export function isSizeEqual(a: Size, b: Size): boolean {
33 1377 : return a.width === b.width && a.height === b.height
34 : }
|