Util
Index
Namespaces
Enumerations
Classes
Interfaces
Type Aliases
Functions
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 = Color.White
The [[Color]] to stroke rectangle with
fill: Color = null
The [[Color]] to fill rectangle with
Returns void
vector
Enumerations
LogLevel
Logging level that Excalibur will tag
Debug
Error
Fatal
Info
Warn
Classes
ConsoleAppender
Console appender for browsers (i.e. console.log
)
constructor
Returns ConsoleAppender
publiclog
Logs a message at the given [[LogLevel]]
Parameters
level: LogLevel
Level to log at
args: any[]
Arguments to log
Returns void
EasingFunctions
Standard easing functions for motion in Excalibur, defined on a domain of [0, duration] and a range from [+startValue,+endValue] Given a time, the function will return a value from positive startValue to positive endValue.
function Linear (t) { return t * t; } // accelerating from zero velocity function EaseInQuad (t) { return t * t; } // decelerating to zero velocity function EaseOutQuad (t) { return t * (2 - t); } // acceleration until halfway, then deceleration function EaseInOutQuad (t) { return t < .5 ? 2 * t * t : -1 + (4 - 2 * t) * t; } // accelerating from zero velocity function EaseInCubic (t) { return t * t * t; } // decelerating to zero velocity function EaseOutCubic (t) { return (--t) * t * t + 1; } // acceleration until halfway, then deceleration function EaseInOutCubic (t) { return t < .5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1; }
constructor
Returns EasingFunctions
publicstaticEaseInCubic
publicstaticEaseInOutCubic
publicstaticEaseInOutQuad
publicstaticEaseInQuad
Type declaration
Parameters
time: number
start: number
end: number
duration: number
Returns number
publicstaticEaseOutCubic
publicstaticEaseOutQuad
publicstaticLinear
publicstaticCreateReversibleEasingFunction
Parameters
easing: EasingFunction
Returns (time: number, start: number, end: number, duration: number) => number
Parameters
time: number
start: number
end: number
duration: number
Returns number
publicstaticCreateVectorEasingFunction
Logger
Static singleton that represents the logging facility for Excalibur. Excalibur comes built-in with a [[ConsoleAppender]] and [[ScreenAppender]]. Derive from [[Appender]] to create your own logging appenders.
constructor
Returns Logger
publicdefaultLevel
Gets or sets the default logging level. Excalibur will only log messages if equal to or above this level. Default: [[LogLevel.Info]]
publicaddAppender
Adds a new [[Appender]] to the list of appenders to write to
Parameters
appender: Appender
Returns void
publicclearAppenders
Clears all appenders from the logger
Returns void
publicdebug
Writes a log message at the [[LogLevel.Debug]] level
Parameters
rest...args: any[]
Accepts any number of arguments
Returns void
publicdebugOnce
Writes a log message once at the [[LogLevel.Fatal]] level, if it sees the same args again it wont log
Parameters
rest...args: any[]
Accepts any number of arguments
Returns void
publicerror
Writes a log message at the [[LogLevel.Error]] level
Parameters
rest...args: any[]
Accepts any number of arguments
Returns void
publicerrorOnce
Writes a log message once at the [[LogLevel.Error]] level, if it sees the same args again it won't log
Parameters
rest...args: any[]
Accepts any number of arguments
Returns void
publicfatal
Writes a log message at the [[LogLevel.Fatal]] level
Parameters
rest...args: any[]
Accepts any number of arguments
Returns void
publicfatalOnce
Writes a log message once at the [[LogLevel.Fatal]] level, if it sees the same args again it won't log
Parameters
rest...args: any[]
Accepts any number of arguments
Returns void
publicinfo
Writes a log message at the [[LogLevel.Info]] level
Parameters
rest...args: any[]
Accepts any number of arguments
Returns void
publicinfoOnce
Writes a log message once at the [[LogLevel.Info]] level, if it sees the same args again it wont log
Parameters
rest...args: any[]
Accepts any number of arguments
Returns void
publicwarn
Writes a log message at the [[LogLevel.Warn]] level
Parameters
rest...args: any[]
Accepts any number of arguments
Returns void
publicwarnOnce
Writes a log message once at the [[LogLevel.Warn]] level, if it sees the same args again it won't log
Parameters
rest...args: any[]
Accepts any number of arguments
Returns void
publicstaticgetInstance
Gets the current static instance of Logger
Returns Logger
Observable
Simple Observable implementation
Type parameters
- T
is the typescript Type that defines the data being observed
constructor
Type parameters
- T
Returns Observable<T>
publicobservers
publicsubscriptions
clear
Removes all observers and callbacks
Returns void
notifyAll
Broadcasts a message to all observers and callbacks
Parameters
message: T
Returns void
register
Register an observer to listen to this observable
Parameters
observer: Observer<T>
Returns void
subscribe
Register a callback to listen to this observable
Parameters
func: (val: T) => any
Returns void
unregister
Remove an observer from the observable
Parameters
observer: Observer<T>
Returns void
unsubscribe
Remove a callback that is listening to this observable
Parameters
func: (val: T) => any
Returns void
ScreenAppender
On-screen (canvas) appender
constructor
Parameters
options: ScreenAppenderOptions
Returns ScreenAppender
publiccanvas
publiclog
Logs a message at the given [[LogLevel]]
Parameters
level: LogLevel
Level to log at
args: any[]
Arguments to log
Returns void
Interfaces
Appender
Contract for any log appender (such as console/screen)
log
Logs a message at the given [[LogLevel]]
Parameters
level: LogLevel
Level to log at
args: any[]
Arguments to log
Returns void
EasingFunction
Parameters
currentTime: number
startValue: number
endValue: number
duration: number
Returns number
Message
Defines a generic message that can contain any data
Type parameters
- T
is the typescript Type of the data
data
type
Observer
Defines an interface for an observer to receive a message via a notify() method
Type parameters
- T
notify
Parameters
message: T
Returns void
ScreenAppenderOptions
optionalcolor
Provide a text color
engine
optionalheight
Optionally set the height of the overlay canvas
optionalwidth
Optionally set the width of the overlay canvas
optionalxPos
Adjust the text offset from the left side of the screen
optionalzIndex
Optionally set the CSS zindex of the overlay canvas
Type Aliases
MaybeObserver
Defines an interface for something that might be an observer if a notify() is present
Type parameters
- T
Functions
addItemToArray
Add an item to an array list if it doesn't already exist. Returns true if added, false if not and already exists in the array.
Type parameters
- T
Parameters
item: T
array: T[]
Returns boolean
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
getPosition
Find the screen position of an HTML element
Parameters
el: HTMLElement
Returns Vector
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 an list
Type parameters
- T
Parameters
item: T
array: T[]
Returns boolean
Represents border radius values