Sprite Class

Sprites are small raster images that are drawn on top of Viewports by a ViewDecoration. Their purpose is to draw the user's attention to something of importance.

There are two classes in the Sprites subsystem: Sprite (a Sprite image) and SpriteLocation. Sprite are the images that define the way a type of sprite looks and are generally loaded one time and saved for the rest of a session. A SpriteLocation defines the current position of a single Sprite in a Viewport.

A SpriteLocation can be either active or inactive. It becomes active by specifying a location (an x,y point) and a Sprite to draw at that point. A Sprite can be used many times by many SpriteLocations and a single SpriteLocation can change both position and which Sprite is shown at that position over time.

Methods

Name Description
constructor(src: ImageSource | string): Sprite construct a Sprite from an ImageSource or a Url  

Properties

Name Type Description
image undefined | HTMLImageElement The image for this Sprite.  
isLoaded Accessor ReadOnly boolean Whether this sprite has be successfully loaded.  
loadPromise Promise<HTMLImageElement> Promise fulfilled when this sprite is loaded.  
offset Accessor ReadOnly Point2d The offset to the middle of this Sprite.  
size Point2d The size of this Sprite.  

Defined in

Last Updated: 13 June, 2024