Class CanvasSource

Constructors

  • Parameters

    • canvasElementOrQuery: string | HTMLCanvasElement
    • sizeBasis: "max" | "min" = ...

    Returns CanvasSource

Accessors

  • get context(): CanvasRenderingContext2D
  • Returns CanvasRenderingContext2D

  • get height(): number
  • Returns number

  • get offset(): {
        x: number;
        y: number;
    }
  • Returns {
        x: number;
        y: number;
    }

    • x: number
    • y: number
  • get sizeScaler(): {
        abs: ((v: number) => number);
        rel: ((v: number) => number);
    }
  • Returns {
        abs: ((v: number) => number);
        rel: ((v: number) => number);
    }

    • abs: ((v: number) => number)
        • (v): number
        • Parameters

          • v: number

          Returns number

    • rel: ((v: number) => number)
        • (v): number
        • Parameters

          • v: number

          Returns number

  • get width(): number
  • Returns number

Methods

  • Returns void

  • Creates a region

    Absolute positioned. Uses source coordinates which don't change

    source.createRegion({ 
    absPositioned: { x: 0, y: 0, width: 100, height: 100}
    });

    Relative positioned. Uses coordiantes relative to source dimensions. Updated if source changes.

    source.createRegion({
    relativePositioned: { x: 0, y:0, width: 1, height: 0.5 },
    scale: `independent`
    });

    Relative sized. Uses size relative to source dimension. By default centers.

    source.createRegion({
    relativeSize: { width: 0.5, height: 0.5 }
    position: `center`
    })

    Parameters

    Returns CanvasRegion

  • Returns void

  • Parameters

    • pt: Point
    • kind: "independent" = ...

    Returns {
        x: number;
        y: number;
    }

    • x: number
    • y: number
  • Parameters

    Returns {
        height: number;
        width: number;
        x: number;
        y: number;
    } | {
        height: number;
        width: number;
    }

  • Parameters

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

    Returns {
        x: number;
        y: number;
    }

    • x: number
    • y: number