Class CanvasRegion

Draws on a canvas, constrained to a specific region

Constructors

Properties

source: CanvasSource

Accessors

  • get context(): CanvasRenderingContext2D
  • Returns CanvasRenderingContext2D

  • get dimensionMin(): number
  • Returns number

  • get height(): number
  • Returns number

  • get width(): number
  • Returns number

  • get x(): number
  • Returns number

  • get y(): number
  • Returns number

Methods

  • Parameters

    • pt: Point
    • source: "screen"
    • clamped: boolean

    Returns {
        x: number;
        y: number;
    }

    • x: number
    • y: number
  • Returns a copy of p offset by the region's x & y

    Parameters

    Returns {
        x: number;
        y: number;
    }

    • x: number
    • y: number
  • Returns void

  • Parameters

    • strokeStyle: string
    • lineWidth: number = 1

    Returns void

  • Parameters

    • relativeCircles: CirclePositioned[]
    • fillStyle: string
    • strokeStyle: string = ...
    • lineWidth: number = 1

    Returns void

  • Draws connected points in absolute coordinates, however with 0,0 being the top-left of the region.

    Thus, this will apply the region offset before drawing.

    Parameters

    • points: Point[]

      Points to draw

    • strokeStyle: string

      Stroke style

    • lineWidth: number = 1

      Line width

    Returns void

  • Draws a line from a series of points. Assumes region-relative, % coordinates (ie 0..1 scale)

    Parameters

    • relativePoints: Point[]

      Points to connect, in region-relative coordinates

    • strokeStyle: string

      Stroke style

    • lineWidth: number = 1

      Line with

    Returns void

  • Parameters

    • fillStyle: string = ...

    Returns void

  • Fills text at a region-relative position

    Parameters

    • text: string
    • point: Point

      Region relative, meaning 0,0 is top-left of region

    • fillStyle: string = ...
    • font: string
    • baseline: CanvasTextBaseline = ...
    • align: CanvasTextAlign = ...

    Returns void

  • Fills text at a relative position

    Parameters

    • text: string
    • relPos: Point

      Relative, meaning 0.5,0.5 is the middle of the region

    • fillStyle: string = ...
    • font: string
    • baseline: CanvasTextBaseline = ...
    • align: CanvasTextAlign = ...

    Returns void

  • Calls the original regionCompute function passed in to the constructor to recompute the absolute region

    Returns void

  • Converts a region-relative point (0..1) to an absolute point, which uses region-relative coordinates.

    Eg if the region had an x,y of 100,100, toAbsRegion({x:0,y:0}) will return 0,0.

    Parameters

    • regionRel: Point
    • scaleBy: "both" = ...

    Returns {
        x: number;
        y: number;
    }

    • x: number
    • y: number
  • Converts a point to a region-relative one.

    Parameters

    • pt: Point
    • source: "source" | "screen" = ...
    • kind: "independent" = ...
    • clamped: boolean = true

    Returns {
        x: number;
        y: number;
    }

    • x: number
    • y: number