Canvas
Hierarchy
- Raster
- Canvas
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
Parameters
_options: GraphicOptions & RasterOptions & CanvasOptions
Returns Canvas
Properties
public_bitmap
publicfiltering
readonlyid
publiclineCap
publicopacity
Gets or sets the opacity of the graphic, 0 is transparent, 1 is solid (opaque).
publicquality
publicshowDebug
Gets or sets wether to show debug information about the graphic
publictint
publictransform
Accessors
publiccolor
publicctx
Return the 2D graphics context of this canvas
Returns CanvasRenderingContext2D
publicdirty
Gets whether the graphic is dirty, this means there are changes that haven't been re-rasterized
Returns boolean
publicflipHorizontal
Gets or sets the flipHorizontal, which will flip the graphic horizontally (across the y axis)
Returns boolean
Parameters
value: boolean
Returns void
publicflipVertical
Gets or sets the flipVertical, which will flip the graphic vertically (across the x axis)
Returns boolean
Parameters
value: boolean
Returns void
publicheight
Gets or sets the current height of the Raster graphic. Setting the height will cause the raster to be flagged dirty causing a re-raster on the next draw.
Any
padding
orquality
set will be factored into the heightReturns number
Parameters
value: number
Returns void
publiclineDash
Returns number[]
Parameters
value: number[]
Returns void
publiclineWidth
Gets or sets the line width of the Raster graphic. Setting the lineWidth will cause the raster to be flagged dirty causing a re-raster on the next draw.
Returns number
Parameters
value: number
Returns void
publiclocalBounds
Returns the local bounds of the Raster including the padding
Returns BoundingBox
publicorigin
publicpadding
Returns number
Parameters
value: number
Returns void
publicrotation
Gets or sets the rotation of the graphic
Returns number
Parameters
value: number
Returns void
publicscale
publicsmoothing
Gets or sets the smoothing (anti-aliasing of the graphic). Setting the height will cause the raster to be flagged dirty causing a re-raster on the next draw.
Returns boolean
Parameters
value: boolean
Returns void
publicstrokeColor
publicwidth
Gets or sets the current width of the Raster graphic. Setting the width will cause the raster to be flagged dirty causing a re-raster on the next draw.
Any
padding
s orquality
set will be factored into the widthReturns number
Parameters
value: number
Returns void
Methods
publicclone
Returns a new instance of the graphic that has the same properties
Returns Canvas
publiccloneGraphicOptions
Returns GraphicOptions
publiccloneRasterOptions
Returns RasterOptions
publicdraw
Draw the whole graphic to the context including transform
Parameters
ex: ExcaliburGraphicsContext
The excalibur graphics context
x: number
y: number
Returns void
execute
Executes drawing implementation of the graphic, this is where the specific drawing code for the graphic should be implemented. Once
rasterize()
the graphic can be drawn to the [[ExcaliburGraphicsContext]] viadraw(...)
Parameters
ctx: CanvasRenderingContext2D
Canvas to draw the graphic to
Returns void
publicflagDirty
Flags the graphic as dirty, meaning it must be re-rasterized before draw. This should be called any time the graphics state changes such that it affects the outputted drawing
Returns void
publicisStale
Returns boolean
publicrasterize
Rasterize the graphic to a bitmap making it usable as in excalibur. Rasterize is called automatically if the graphic is [[Raster.dirty]] on the next [[Graphic.draw]] call
Returns void
A canvas [[Graphic]] to provide an adapter between the 2D Canvas API and the [[ExcaliburGraphicsContext]].
The [[Canvas]] works by re-rastering a draw handler to a HTMLCanvasElement for every draw which is then passed to the [[ExcaliburGraphicsContext]] implementation as a rendered image.
Low performance API