-
Notifications
You must be signed in to change notification settings - Fork 0
ImageNode
hhh edited this page Jan 28, 2023
·
6 revisions
/**
* Type of image sources of image nodes.
*/
type ImageNodeSource = Exclude<CanvasImageSource, SVGImageElement>;
/**
* Type of options of {@link ImageNode}.
*/
type ImageNodeOptions<Events extends CanvasNodeEvents> = (CanvasNodeOptions<Events> & Partial<{
/**
* Image source.
* @default null
*/
image: ImageNodeSource | null;
/**
* Offset x in image source.
* @default 0
*/
sourceX: number;
/**
* Offset y in image source.
* @default 0
*/
sourceY: number;
/**
* Image width in source.
* (`image.width` will be used if this is set to zero.)
* @default 0
*/
sourceWidth: number;
/**
* Image height in source.
* (`image.height` will be used if this is set to zero.)
* @default 0
*/
sourceHeight: number;
/**
* Destination width.
* (`image.width` will be used if this is set to zero.)
* @default 0
*/
destinationWidth: number;
/**
* Destination height.
* (`image.height` will be used if this is set to zero.)
* @default 0
*/
destinationHeight: number;
/**
* Whether to set `destinationWidth` and `destinationHeight` to
* `bounds.width` and `bounds.height` on update.
* (Try this with stretch options!)
* @default false
*/
smartSize: boolean;
}>);
/**
* Class of image nodes.
*/
class ImageNode<Events extends CanvasNodeEvents = CanvasNodeEvents> extends CanvasNode<Events> {
/**
* Constructor of {@link ImageNode}.
*/
constructor(options?: ImageNodeOptions<Events>);
/**
* @override CanvasNode.tag
*/
readonly tag: string;
/**
* Image source.
* @default null
*/
image: ImageNodeSource | null;
/**
* Offset x in image source.
* @default 0
*/
sourceX: number;
/**
* Offset y in image source.
* @default 0
*/
sourceY: number;
/**
* Image width in source.
* (Default to `image.width`.)
* @default 0
*/
sourceWidth: number;
/**
* Image height in source.
* (Default to `image.height`.)
* @default 0
*/
sourceHeight: number;
/**
* Destination width.
* (Default to `this.sourceWidth`.)
* @default 0
*/
destinationWidth: number;
/**
* Destination height.
* (Default to `this.sourceHeight`.)
* @default 0
*/
destinationHeight: number;
/**
* Whether to set `destinationWidth` and `destinationHeight` to
* `bounds.width` and `bounds.height` on update.
* (Try this with stretch options!)
* @default false
*/
smartSize: boolean;
/**
* @override CanvasNode.beforeUpdate
*/
protected beforeUpdate(timeStamp: number): void;
/**
* @override CanvasNode.renderSelf
*/
protected renderSelf(renderer: Renderer): void;
/**
* @override CanvasNode.getRecordOptions
*/
getRecordOptions(): NodeRecordOptions;
}