Text

Text

new Text(label, font)

Parameters:
Name Type Description
label string | number The words of the text.
font string String of the desired font of the text.
Source:

Extends

Methods

(static) giveDefaultContext(__graphics__)

Define a default context for the text. Text objects need access to some 2d graphics context to compute height and width. This might be done before a draw call.
Parameters:
Name Type Description
__graphics__ CodeHSGraphics Instance of the graphics module.
Source:

containsPoint(x, y) → {boolean}

Checks if the passed point is contained in the text.
Parameters:
Name Type Description
x number The x coordinate of the point being tested.
y number The y coordinate of the point being tested.
Overrides:
Source:
Returns:
Whether the passed point is contained in the text.
Type
boolean

draw(__graphics__)

Draw the text in the current context.
Parameters:
Name Type Description
__graphics__ CodeHSGraphics Instance of the graphics module.
Overrides:
Source:

getBorderColor() → {Color}

Gets the border color of a Thing.
Inherited From:
Source:
Returns:
The color of the Thing's border.
Type
Color

getBorderWidth() → {number}

Gets the width of the Thing's border.
Inherited From:
Source:
Returns:
The width of the Thing's border.
Type
number

getColor() → {Color}

Gets the color of a Thing.
Inherited From:
Source:
Returns:
The destination y coordinate of this Thing.
Type
Color

getHeight() → {number}

Returns the height of a Text object.
Source:
Returns:
The height of the text.
Type
number

getLabel() → {string}

Returns the label of a Text object.
Source:
Returns:
String of the Text's current label.
Type
string

getText() → {string}

Equivalent to `getLabel`. Likely created to prevent errors on accidental calls. Returns the label of a Text object.
Source:
Returns:
String of the Text's current label.
Type
string

getType() → {type}

Returns the type of a Thing.
Inherited From:
Source:
Returns:
The type of the Thing.
Type
type

getWidth() → {number}

Returns the width of a Text object.
Source:
Returns:
The width of the text.
Type
number

getX() → {number}

Gets the x position of the Thing.
Inherited From:
Source:
Returns:
The x position of the Thing.
Type
number

getY() → {number}

Gets the y position of the Thing.
Inherited From:
Source:
Returns:
The y position of the Thing.
Type
number

hasBorder() → {boolean}

Returns if a Thing has a border.
Inherited From:
Source:
Returns:
True if the Thing has a border.
Type
boolean

isFilled() → {boolean}

Returns if a Thing is filled.
Inherited From:
Source:
Returns:
True if the Thing is filled.
Type
boolean

move(dx, dy)

Changes the possition of a thing by a specified x and y amount.
Parameters:
Name Type Description
dx number The resulting change in the Thing's x position.
dy number The resulting change in the Thing's y position.
Inherited From:
Source:

resetDimensions()

Reset the dimensions of the text to the size in the context.
Source:

rotate(degrees, angleUnit)

Rotates a Thing an additional amount of degrees.
Parameters:
Name Type Description
degrees number The degrees to rotate degrees.
angleUnit number Whether it is degrees or radians. Defaults to degrees.
Inherited From:
Source:

setBorder(hasBorder)

Sets a Thing object to filled. Throws an error if an argument is not passed.
Parameters:
Name Type Description
hasBorder bool A boolean of whether or not Thing has a border.
Inherited From:
Source:

setBorderColor(color)

Sets the border color of a Thing. Throws an error if there are fewer than 1 params or if the param is undefined.
Parameters:
Name Type Description
color Color The resulting color of the Thing's border.
Inherited From:
Source:

setBorderWidth(width)

Sets the width of a Thing's border. Throws an error if there is not 1 argument.
Parameters:
Name Type Description
width number The resulting width of the Thing's border.
Inherited From:
Source:

setColor(color)

Sets the color of a Thing. Throws an error if there are fewer than 1 params or if the param is undefined.
Parameters:
Name Type Description
color Color The resulting color of Thing.
Inherited From:
Source:

setFilled(filled)

Sets a Thing object to filled. Throws an error if an argument is not passed.
Parameters:
Name Type Description
filled bool A boolean of whether or not Thing is filled.
Inherited From:
Source:

setFont(font)

Set the font of the text. Re-calculates the dimensions of the font after font change.
Parameters:
Name Type Description
font string String of the desired font for the text.
Source:

setLabel(label)

Set the label of the text. Re-calculates the dimensions of the font after font change.
Parameters:
Name Type Description
label string | number The words of the text.
Source:

setPosition(x, y)

Sets the position of a Thing. Throws an error if there are fewer than 2 params or if they are not numbers.
Parameters:
Name Type Description
x number The destination x coordinate of this Thing.
y number The destination y coordinate of this Thing.
Inherited From:
Source:

setRotation(degrees, angleUnit)

Sets the rotation of a Thing in degrees. Throws an error if there are fewer than 1 params or if they are not numbers.
Parameters:
Name Type Description
degrees number The degrees to rotate degrees.
angleUnit number Whether it is degrees or radians. Defaults to degrees.
Inherited From:
Source:

setText(label)

Equivalent to `setLabel`. Likely created to prevent errors on accidental calls. Re-calculates the dimensions of the font after font change.
Parameters:
Name Type Description
label string | number The words of the text.
Source:

setType(type)

Sets a Thing object's type. Questionable of whether or not this method is used.
Parameters:
Name Type Description
type type A type to set the Thing to.
Inherited From:
Source: