Accessors

  • get visibleRect(): Rect2
  • Get the screen's visible region transformed into canvas space.

    Returns Rect2

Methods

  • Parameters

    Returns Vec3

    the given point transformed into screen coordinates.

  • Computes and returns an affine transformation that makes toMakeVisible visible and roughly centered on the screen.

    Parameters

    • toMakeVisible: Rect2
    • allowZoomIn: boolean = true
    • allowZoomOut: boolean = true

    Returns Mat33

  • Returns number

    the angle of the canvas in radians. This is the angle by which the canvas is rotated relative to the screen.

    Returns an angle in the range [π,π][-\pi, \pi] (the same range as Vec3.angle).

  • Returns number

    the amount a vector on the canvas is scaled to become a vector on the screen.

  • Returns number

    getScaleFactor() rounded to the nearest power of 10. For example, if getScaleFactor() returns 101, getScaleFactorToNearestPowerOfTen() should return 100 because 100 is the nearest power of 10 to 101.

  • Returns Vec3

    the size of the visible region in pixels (screen units).

  • Returns the size of one screen pixel in canvas units.

    Returns number

  • Returns Viewport

    a temporary copy of this that does not notify when modified. This is useful when rendering with a temporarily different viewport.

  • Updates the transformation directly. Using transformBy is preferred.

    Parameters

    • newTransform: Mat33 = Mat33.identity

      should map from canvas coordinates to screen coordinates.

    Returns void

  • Parameters

    Returns Vec3

    the given point, but in canvas coordinates

  • Returns a Command that transforms the view such that [rect] is visible, and perhaps centered in the viewport. Returns null if no transformation is necessary

    Parameters

    • toMakeVisible: Rect2
    • allowZoomIn: boolean = true
    • allowZoomOut: boolean = true

    Returns Command

  • Returns the size of a grid cell (in canvas units) as used by snapToGrid.

    Parameters

    • scaleFactor: number

    Returns number

  • Rounds the given point to a multiple of 10 such that it is within tolerance of its original location. This is useful for preparing data for base-10 conversion.

    Type Parameters

    • T extends number | Vec3

    Parameters

    • point: T
    • tolerance: number

    Returns PointDataType<T>

  • roundAmount: An integer >= 0, larger numbers cause less rounding. Smaller numbers cause more (as such roundAmount = 0 does the most rounding).

    Parameters

    • scaleRatio: number
    • roundAmount: number = 1

    Returns number

  • Parameters

    Returns ViewportTransform

    a command that transforms the canvas by transform.

OpenSource licenses