Graphics.ImageSource
Description: Defines an image resource that can be used within Sprite's, SpriteAnimation's and other drawable graphics.
Implements: EndGate.IDisposable , EndGate.ICloneable
Constructors
ImageSource (image)
Creates a new instance of the ImageSource object with a pre-loaded image object.
image: HTMLImageElement
Image object to use as the source.
ImageSource (imageLocation)
Creates a new instance of the ImageSource object.
imageLocation: string
Image source url (this cannot change after construction).
ImageSource (imageLocation, width, height)
Creates a new instance of the ImageSource object with a specified width and height. ClipSize defaults to the full size and the ClipLocation defaults to (0,0). If width and height are not equal to the actual width and height of the image source the image will be stretched
imageLocation: string
Image source url (this cannot change after construction).
width: number
The width of the base image (this cannot change after construction).
height: number
The height of the base image (this cannot change after construction).
ImageSource (image, clipX, clipY, clipWidth, clipHeight)
Creates a new instance of the ImageSource object with a specified width and height and a clip location. If width and height are smaller than the actual width and height of the image source the image will be stretched
image: HTMLImageElement
Image object to use as the source.
clipX: number
The horizontal location of the clip.
clipY: number
The vertical location of the clip.
clipWidth: number
The width of the clip. Ultimately this width is the width that is drawn to the screen.
clipHeight: number
The height of the clip. Ultimately this height is the height that is drawn to the screen.
ImageSource (imageLocation, width, height, clipX, clipY, clipWidth, clipHeight)
Creates a new instance of the ImageSource object with a specified width and height and a clip location. If width and height are smaller than the actual width and height of the image source the image will be stretched
imageLocation: string
Image source url (this cannot change after construction).
width: number
The width of the base image (this cannot change after construction).
height: number
The height of the base image (this cannot change after construction).
clipX: number
The horizontal location of the clip.
clipY: number
The vertical location of the clip.
clipWidth: number
The width of the clip. Ultimately this width is the width that is drawn to the screen.
clipHeight: number
The height of the clip. Ultimately this height is the height that is drawn to the screen.
Fields
ClipLocation: EndGate.Vector2d
Gets or sets the ClipLocation. Represents where the image clip is within the base image.
ClipSize: EndGate.Size2d
Gets or sets the ClipSize. Represents how large the image clip is within the base image.
Source: HTMLImageElement
Gets the base image source. Should not be modified once the ImageSource has been constructed
OnLoaded: EndGate.EventHandler1 <ImageSource>
Gets an event that is triggered when the base image is finished loading. Functions can be bound or unbound to this event to be executed when the event triggers.
Methods
IsLoaded()
Determines if the ImageSource has been loaded.
Extract()
Returns an ImageSource that is extracted from the current ImageSource based on the provided clip location and clip size.
Dispose()
Disposes the image source and unbinds all bound events.
Clone()
Returns an identical copy of this image source. Uses existing base image source.
Examples
There's currently no example available for this page. If you'd like to suggest one send me an containing a description, code, and link to the page for the suggested example. As a thanks I'll associate the code snippet with your name directly below the example if approved.