a Text Metrics object that contains helper for text manipulation

Hierarchy (view full)

Constructors

Properties

_center: Vector2d
ancestor: Renderable

a reference to the parent object that contains this TextMetrics object

undefined
max: XYPoint
min: XYPoint
type: "Bounds"

Accessors

Methods

  • Adds the given vertices to the bounds definition.

    Parameters

    • vertices: Vector2d[] | Point[] | XYPoint[]

      An array of Vector2d or Point to add to the bounds.

    • Optionalclear: boolean = false

      Whether to reset the bounds before adding the new vertices. Defaults to false.

    Returns void

  • Adds the given quad coordinates to this bounds definition, multiplied by the given matrix.

    Parameters

    • x0: number

      The left x coordinate of the quad.

    • y0: number

      The top y coordinate of the quad.

    • x1: number

      The right x coordinate of the quad.

    • y1: number

      The bottom y coordinate of the quad.

    • Optionalm: Matrix2d

      An optional transform to apply to the given coordinates.

    Returns void

  • Sets the bounds to the given minimum and maximum values.

    Parameters

    • minX: number

      The minimum x value.

    • minY: number

      The minimum y value.

    • maxX: number

      The maximum x value.

    • maxY: number

      The maximum y value.

    Returns void

  • wrap the given text based on the given width

    Parameters

    • text: string | string[]

      the text to be wrapped

    • width: number

      maximum width of one segment of text in css pixel

    • Optionalcontext: CanvasRenderingContext2D

      reference to an active 2d context for canvas rendering

    Returns string[]

    an array of string representing wrapped text