Util
Index
Namespaces
DrawUtil
BorderRadius
bl
Bottom-left
br
Bottom-right
tl
Top-left
tr
Top-right
LineCapStyle
A canvas linecap style. "butt" is the default flush style, "round" is a semi-circle cap with a radius half the width of the line, and "square" is a rectangle that is an equal width and half height cap.
circle
line
Draw a line on canvas context
Parameters
ctx: CanvasRenderingContext2D
The canvas context
color: Color = Color.Red
The color of the line
x1: number
The start x coordinate
y1: number
The start y coordinate
x2: number
The ending x coordinate
y2: number
The ending y coordinate
thickness: number = 1
The line thickness
cap: LineCapStyle = 'butt'
The LineCapStyle (butt, round, or square)
Returns void
point
roundRect
Draw a round rectangle on a canvas context
Parameters
ctx: CanvasRenderingContext2D
The canvas context
x: number
The top-left x coordinate
y: number
The top-left y coordinate
width: number
The width of the rectangle
height: number
The height of the rectangle
radius: number | BorderRadius = 5
The border radius of the rectangle
stroke: Color | null = Color.White
The Color to stroke rectangle with
fill: Color | null = null
The Color to fill rectangle with
Returns void
vector
Functions
contains
See if an array contains something
Parameters
array: any[]
obj: any
Returns boolean
delay
Create a promise that resolves after a certain number of milliseconds
It is strongly recommended you pass the excalibur clock so delays are bound to the excalibur clock which would be unaffected by stop/pause.
Parameters
milliseconds: number
optionalclock: Clock
Returns Promise<void>
fail
Used for exhaustive checks at compile time
Parameters
message: never
Returns never
getMinIndex
Parameters
array: number[]
Returns number
getPosition
Find the screen position of an HTML element
Parameters
el: HTMLElement
Returns Vector
isObject
Simple object check.
Parameters
item: any
Returns item is object
mergeDeep
Deep merge two objects.
Type parameters
- T: object
Parameters
target: T
rest...sources: T[]
Returns T
omit
Remove keys from object literals
Type parameters
- TObject: Object
- Keys: string | number | symbol
Parameters
object: TObject
keys: Keys[]
Returns Omit<TObject, Keys>
removeItemFromArray
Remove an item from a list, returns true if the item was found and removed
Type parameters
- T
Parameters
item: T
array: T[]
Returns boolean
Represents border radius values