-
Notifications
You must be signed in to change notification settings - Fork 0
Utils
hhh edited this page Jan 28, 2023
·
15 revisions
/**
* Utilities.
*/
namespace Utils {
/**
* Constants.
*/
namespace Constants {
/**
* `'rgba(0,0,0,0)'`
*/
const TRANSPARENT = "rgba(0,0,0,0)";
/**
* `Math.PI`
*/
const PI: number;
/**
* `Math.PI / 2`
*/
const HALF_PI: number;
/**
* `Math.PI / 2 * 3`
*/
const THREE_HALVES_PI: number;
/**
* `Math.PI * 2`
*/
const TWO_PI: number;
/**
* Whether the device supports touch events.
* (`navigator.maxTouchPoints > 0`)
*/
const SUPPORTS_TOUCH_EVENTS: boolean;
}
/**
* Extract value types from specific map type.
*/
type ValueType<T extends {}> = T[keyof T];
/**
* Emits an event following the given target path.
* (From the last one to the first one;
* stops if the event is stopped by `event.stop`.)
*/
const bubbleEvent: (event: ValueType<CanvasNodeEvents>, targetPath: CanvasNode<any>[]) => void;
/**
* Select a descendent node with specific id.
* (Returns `null` if not found.)
*/
const selectId: (id: string, node: CanvasNode<any>) => CanvasNode<any> | null;
/**
* Select descendent nodes with specific tag name.
*/
const selectTag: (tag: string, node: CanvasNode<any>, output?: CanvasNode<any>[]) => CanvasNode<any>[];
/**
* Select descendent nodes with specific class name.
*/
const selectClass: (className: string, node: CanvasNode<any>, output?: CanvasNode<any>[]) => CanvasNode<any>[];
}