Class: HorizonCanvasLayer<P, C>
Defined in: src/sdk/components/horizon/layers/HorizonCanvasLayer.tsx:72
A layer which uses a canvas to draw graphics.
Extends
HorizonLayer
<P
>
Extended by
Type Parameters
Type Parameter | Default type |
---|---|
P extends HorizonCanvasLayerProps | HorizonCanvasLayerProps |
C extends HorizonCanvasLayerCanvasInstance | HorizonCanvasLayerCanvasInstance |
Constructors
Constructor
new HorizonCanvasLayer<
P
,C
>(props
):HorizonCanvasLayer
<P
,C
>
Defined in: src/sdk/components/FSComponent.ts:73
Creates an instance of a DisplayComponent.
Parameters
Parameter | Type | Description |
---|---|---|
props | P | The propertis of the component. |
Returns
HorizonCanvasLayer
<P
, C
>
Inherited from
Properties
context?
optional
context: [] =undefined
Defined in: src/sdk/components/FSComponent.ts:64
The context on this component, if any.
Inherited from
contextType?
readonly
optional
contextType: readonly [] =undefined
Defined in: src/sdk/components/FSComponent.ts:67
The type of context for this component, if any.
Inherited from
isInit
protected
isInit:boolean
=false
Defined in: src/sdk/components/horizon/layers/HorizonCanvasLayer.tsx:82
props
props:
P
&ComponentProps
Defined in: src/sdk/components/FSComponent.ts:61
The properties of the component.
Inherited from
Accessors
buffer
Get Signature
get buffer():
C
Defined in: src/sdk/components/horizon/layers/HorizonCanvasLayer.tsx:102
Gets this layer's buffer canvas instance.
Throws
Error if this layer's buffer canvas instance has not been initialized.
Returns
C
This layer's buffer canvas instance.
display
Get Signature
get display():
C
Defined in: src/sdk/components/horizon/layers/HorizonCanvasLayer.tsx:89
Gets this layer's display canvas instance.
Throws
Error if this layer's display canvas instance has not been initialized.
Returns
C
This layer's display canvas instance.
Methods
copyBufferToDisplay()
copyBufferToDisplay():
void
Defined in: src/sdk/components/horizon/layers/HorizonCanvasLayer.tsx:175
Copies the contents of the buffer to the display. Has no effect if this layer does not have a buffer.
Returns
void
createCanvasInstance()
protected
createCanvasInstance(canvas
,context
,isDisplayed
):C
Defined in: src/sdk/components/horizon/layers/HorizonCanvasLayer.tsx:226
Creates a canvas instance.
Parameters
Parameter | Type | Description |
---|---|---|
canvas | HTMLCanvasElement | The canvas element. |
context | CanvasRenderingContext2D | The canvas 2D rendering context. |
isDisplayed | boolean | Whether the canvas is displayed. |
Returns
C
a canvas instance.
destroy()
destroy():
void
Defined in: src/sdk/components/FSComponent.ts:98
Destroys this component.
Returns
void
Inherited from
getContext()
protected
getContext(context
):never
Defined in: src/sdk/components/FSComponent.ts:106
Gets a context data subscription from the context collection.
Parameters
Parameter | Type | Description |
---|---|---|
context | never | The context to get the subscription for. |
Returns
never
The requested context.
Throws
An error if no data for the specified context type could be found.
Inherited from
getHeight()
getHeight():
number
Defined in: src/sdk/components/horizon/layers/HorizonCanvasLayer.tsx:138
Gets the height of the canvas element, in pixels.
Returns
number
the height of the canvas element.
getWidth()
getWidth():
number
Defined in: src/sdk/components/horizon/layers/HorizonCanvasLayer.tsx:130
Gets the width of the canvas element, in pixels.
Returns
number
the width of the canvas element.
isAttached()
protected
isAttached():boolean
Defined in: src/sdk/components/horizon/HorizonLayer.ts:31
Checks whether this layer is attached to a horizon component.
Returns
boolean
Whether this layer is attached to a horizon component.
Inherited from
isVisible()
isVisible():
boolean
Defined in: src/sdk/components/horizon/HorizonLayer.ts:39
Checks whether this layer is visible.
Returns
boolean
whether this layer is visible.
Inherited from
onAfterRender()
onAfterRender():
void
Defined in: src/sdk/components/horizon/layers/HorizonCanvasLayer.tsx:186
A callback called after the component renders.
Returns
void
Overrides
onAttached()
onAttached():
void
Defined in: src/sdk/components/horizon/layers/HorizonCanvasLayer.tsx:198
This method is called when this layer is attached to its parent horizon component.
Returns
void
Overrides
onBeforeRender()
onBeforeRender():
void
Defined in: src/sdk/components/FSComponent.ts:80
A callback that is called before the component is rendered.
Returns
void
Inherited from
onDetached()
onDetached():
void
Defined in: src/sdk/components/horizon/HorizonLayer.ts:115
This method is called when this layer is detached from its parent horizon component.
Returns
void
Inherited from
onProjectionChanged()
onProjectionChanged(
projection
,changeFlags
):void
Defined in: src/sdk/components/horizon/HorizonLayer.ts:98
This method is called when this layer's horizon projection changes.
Parameters
Parameter | Type | Description |
---|---|---|
projection | HorizonProjection | This layer's horizon projection. |
changeFlags | number | The types of changes made to the projection. |
Returns
void
Inherited from
HorizonLayer
.onProjectionChanged
onSleep()
onSleep():
void
Defined in: src/sdk/components/horizon/HorizonLayer.ts:88
This method is called when this layer's parent horizon component is put to sleep.
Returns
void
Inherited from
onUpdated()
onUpdated(
time
,elapsed
):void
Defined in: src/sdk/components/horizon/HorizonLayer.ts:108
This method is called once every update cycle.
Parameters
Parameter | Type | Description |
---|---|---|
time | number | The current time as a UNIX timestamp in milliseconds. |
elapsed | number | The elapsed time, in milliseconds, since the last update. |
Returns
void
Inherited from
onVisibilityChanged()
protected
onVisibilityChanged():void
Defined in: src/sdk/components/horizon/layers/HorizonCanvasLayer.tsx:191
This method is called when this layer's visibility changes.
Returns
void
Overrides
HorizonLayer
.onVisibilityChanged
onWake()
onWake():
void
Defined in: src/sdk/components/horizon/HorizonLayer.ts:81
This method is called when this layer's parent horizon component is awakened.
Returns
void
Inherited from
render()
render():
VNode
Defined in: src/sdk/components/horizon/layers/HorizonCanvasLayer.tsx:255
Renders the component.
Returns
A JSX element to be rendered.
Overrides
setHeight()
setHeight(
height
):void
Defined in: src/sdk/components/horizon/layers/HorizonCanvasLayer.tsx:161
Sets the height of the canvas element, in pixels.
Parameters
Parameter | Type | Description |
---|---|---|
height | number | The new height. |
Returns
void
setVisible()
setVisible(
val
):void
Defined in: src/sdk/components/horizon/HorizonLayer.ts:47
Sets this layer's visibility.
Parameters
Parameter | Type | Description |
---|---|---|
val | boolean | Whether this layer should be visible. |
Returns
void
Inherited from
setWidth()
setWidth(
width
):void
Defined in: src/sdk/components/horizon/layers/HorizonCanvasLayer.tsx:146
Sets the width of the canvas element, in pixels.
Parameters
Parameter | Type | Description |
---|---|---|
width | number | The new width. |
Returns
void
tryGetBuffer()
tryGetBuffer():
undefined
|C
Defined in: src/sdk/components/horizon/layers/HorizonCanvasLayer.tsx:122
Attempts to get this layer's buffer canvas instance.
Returns
undefined
| C
This layer's buffer canvas instance, or undefined if it has not been initialized.
tryGetDisplay()
tryGetDisplay():
undefined
|C
Defined in: src/sdk/components/horizon/layers/HorizonCanvasLayer.tsx:114
Attempts to get this layer's display canvas instance.
Returns
undefined
| C
This layer's display canvas instance, or undefined if it has not been initialized.
updateCanvasSize()
protected
updateCanvasSize():void
Defined in: src/sdk/components/horizon/layers/HorizonCanvasLayer.tsx:233
Updates the canvas element's size.
Returns
void