@palco-2d/core / Text
Class: Text
Defined in: src/Text.ts:26
BaseEntity serves as the foundational class for all entities managed by the rendering and mouse handling systems. It encapsulates the essential properties and methods shared across all entities, ensuring seamless integration with rendering and interactive functionalities. Any custom entity should extend this class to be properly managed by the engine, maintaining consistency in interactivity and rendering behavior
Extends
Constructors
new Text()
new Text(
props):Text
Defined in: src/Text.ts:36
Parameters
props
TextProps
Returns
Overrides
Properties
children
children:
Map<number,Map<string,BaseEntity>>
Defined in: src/BaseEntity.ts:162
A map representing the children organized by layers.
[
[layer]: [
[id]: BaseEntity
]
]
Inherited from
color
color:
string="black"
Defined in: src/Text.ts:28
coords
coords:
Coords
Defined in: src/BaseEntity.ts:103
The coordinates of the entity in the canvas. represents the for corners of the entity in the canvas, and the bounding box of that these corners describes.
Inherited from
dimations
dimations:
Vec2
Defined in: src/Text.ts:33
font
font:
string="Arial"
Defined in: src/Text.ts:30
fontSize
fontSize:
number=20
Defined in: src/Text.ts:31
globalCompositeOperation
globalCompositeOperation:
GlobalCompositeOperation="source-over"
Defined in: src/BaseEntity.ts:222
The globalCompositeOperation property sets the type of compositing operation to apply when drawing the render method. The default value is source-over.
Inherited from
BaseEntity.globalCompositeOperation
id
id:
string
Defined in: src/BaseEntity.ts:35
The unique id of the entity.
Inherited from
isMouseHover
isMouseHover:
boolean
Defined in: src/BaseEntity.ts:141
If the mouse is hovering the entity it returns true, otherwise false.
Inherited from
isUI
isUI:
boolean=false
Defined in: src/BaseEntity.ts:216
When isUI is set to true the entity will be render in the upper canvas, when the mouse detection will preoritize the UI entities over others.
Inherited from
layer
layer:
number
Defined in: src/BaseEntity.ts:150
The layer of the entity represents the order the render handler will render the entity. 0 is the first layer, and the entities with higher layers will be rendered on top of the entities with lower layers. The layer is relative to the parent, so if the entity is a child, the layer is relative to the parent. If the entity has a layer equal to 0, and the parent has a layer equal to 10, any entity with layer less than 10, that's not a child of a parent, will be rendered before.
Inherited from
mask
mask:
Mask
Defined in: src/BaseEntity.ts:174
Mask Handler to handle the masking of the entity.
Inherited from
matrix
matrix:
number[][] =[]
Defined in: src/BaseEntity.ts:116
The matrix of the entity, used to calculate the transformation of the entity.
Inherited from
maxWidth
maxWidth:
number=undefined
Defined in: src/Text.ts:32
onEntityEvent
onEntityEvent:
EntityEvents
Defined in: src/BaseEntity.ts:169
A record of events that the entity has subscribed to. Mouse handler will trigger these events depending on the interaction with the entity. if the entity is static, the mouse handler will not trigger any event.
Inherited from
quadrant
quadrant:
EntityQuadrant
Defined in: src/BaseEntity.ts:233
The canvas is divided into quadrants, and each entity is assigned to a quadrant. these quadrants are used to optimize the mouse detection over the entities, preventing the mouse checking for all entities in the canvas, it will only check for the ones within the same quadrant as the mouse. quadrant represents all the quadrants the entity is assigned, depending on the transformation of the entity, it can have assigned multiple quadrants. The quadrant updated when the entity matrix changes.
Inherited from
shadow
shadow:
Shadow=undefined
Defined in: src/Text.ts:34
stroke
stroke:
Stroke=undefined
Defined in: src/Text.ts:29
text
text:
string=""
Defined in: src/Text.ts:27
Accessors
parent
Get Signature
get parent():
BaseEntity
Defined in: src/BaseEntity.ts:197
Returns
Set Signature
set parent(
parent):void
Defined in: src/BaseEntity.ts:201
Parameters
parent
Returns
void
Inherited from
position
Get Signature
get position():
Vec2
Defined in: src/BaseEntity.ts:45
The position of the entity in the canvas, relative to the top-left corner. if the entity is a child, the position is relative to the parent.
Returns
Vec2
Set Signature
set position(
position):void
Defined in: src/BaseEntity.ts:49
Parameters
position
Vec2
Returns
void
Inherited from
realSize
Get Signature
get realSize():
Vec2
Defined in: src/BaseEntity.ts:94
The size of the element property (not considering canvas transformation)
Returns
Vec2
Vec2
Inherited from
rotation
Get Signature
get rotation():
number
Defined in: src/BaseEntity.ts:124
Returns
number
Set Signature
set rotation(
rotation):void
Defined in: src/BaseEntity.ts:128
Parameters
rotation
number
Returns
void
Inherited from
size
Get Signature
get size():
Vec2
Defined in: src/BaseEntity.ts:67
The size of the entity in the canvas. if the entity is a child, the size is relative to the parent.
Returns
Vec2
Set Signature
set size(
size):void
Defined in: src/BaseEntity.ts:75
Parameters
size
Vec2
Returns
void
Inherited from
useAsMask
Get Signature
get useAsMask():
boolean
Defined in: src/BaseEntity.ts:180
When set to true children elements will be masked Note: When using and element as a mask globalCompositeOperation does not take effect
Returns
boolean
Set Signature
set useAsMask(
enable):void
Defined in: src/BaseEntity.ts:184
Parameters
enable
boolean
Returns
void
Inherited from
Methods
addChild()
addChild(
child):void
Defined in: src/BaseEntity.ts:475
Parameters
child
Returns
void
Inherited from
destroy()
destroy():
void
Defined in: src/BaseEntity.ts:504
Returns
void
Inherited from
getCoords()
protectedgetCoords():Coords
Defined in: src/BaseEntity.ts:354
Gets the coords of the entity in the canvas. the coords are the corners of the entity in the canvas. eg: top-left, top-right, bottom-right, bottom-left
Returns
Coords
Inherited from
getIdAddress()
getIdAddress():
string
Defined in: src/BaseEntity.ts:604
Get the string address of the entity. With the address id you can get any entity in the scene, it represents the path to the entity.
Returns
string
Example
{layer}:{id}/{layer}:{id}/{layer}:{id}
the first layer and id is the entity itself, the next layers and ids are the parents of the entity.
Inherited from
getMatrix()
protectedgetMatrix():number[][]
Defined in: src/BaseEntity.ts:337
Gets the transformation matrix of the entity,
Returns
number[][]
Inherited from
getOwnAddress()
getOwnAddress():
string
Defined in: src/BaseEntity.ts:614
Returns
string
Inherited from
getPivotPosition()
getPivotPosition():
object
Defined in: src/BaseEntity.ts:293
Returns
object
x
x:
number
y
y:
number
Inherited from
getRelativePosition()
getRelativePosition(
mousePosition,relativeToParent?):object
Defined in: src/BaseEntity.ts:419
Parameters
mousePosition
Vec2
relativeToParent?
boolean
Returns
object
x
x:
number
y
y:
number
Inherited from
BaseEntity.getRelativePosition
getScale()
getScale():
object
Defined in: src/BaseEntity.ts:279
Returns
object
x
x:
number=1
y
y:
number=1
Inherited from
getStatic()
getStatic():
boolean
Defined in: src/BaseEntity.ts:623
Returns
boolean
Inherited from
getWorldMatrix()
getWorldMatrix():
number[][]
Defined in: src/BaseEntity.ts:317
Returns
number[][]
Inherited from
isObjectInViewport()
isObjectInViewport(
viewport):boolean
Defined in: src/BaseEntity.ts:550
Parameters
viewport
position
Vec2
size
Vec2
Returns
boolean
Inherited from
isPointOverEntity()
isPointOverEntity(
point):boolean
Defined in: src/BaseEntity.ts:527
Check if the point is over the entity.
Parameters
point
Vec2
Returns
boolean
Inherited from
on()
on(
event,callback):void
Defined in: src/BaseEntity.ts:274
Parameters
event
EventsType
callback
() => void
Returns
void
Inherited from
removeChild()
removeChild(
address):void
Defined in: src/BaseEntity.ts:492
Parameters
address
string
Returns
void
Inherited from
render()
render(
ctx):void
Defined in: src/Text.ts:58
Parameters
ctx
CanvasRenderingContext2D
Returns
void
Overrides
serialize()
serialize():
object
Defined in: src/Text.ts:83
Returns
object
address
address:
string
children
children:
SerializedBaseEntityProps<BaseEntityProps>[]
color
color:
string
font
font:
string
fontSize
fontSize:
number
globalCompositeOperation?
optionalglobalCompositeOperation:GlobalCompositeOperation
id?
optionalid:string
isUI?
optionalisUI:boolean
layer?
optionallayer:number
maxWidth
maxWidth:
number
position
position:
Vec2
rotation?
optionalrotation:number
shadow
shadow:
Shadow
size
size:
Vec2
static?
optionalstatic:boolean
stroke
stroke:
Stroke
text
text:
string
type
type:
string="text"
useAsMask?
optionaluseAsMask:boolean
Overrides
setStatic()
setStatic(
staticValue):void
Defined in: src/BaseEntity.ts:618
Parameters
staticValue
boolean
Returns
void