Options
All
  • Public
  • Public/Protected
  • All
Menu
summary

The CanvasTexture is used internally to map an {@link HTMLCanvasElement} to a WebGL Texture. Use this when you want to create a WebGL texture and draw on it.

remarks

To use a canvas texture, declare one, draw on the HTML canvas, then call CanvasTexture.copyTexture. Code example below

// Create a canvasTexture
const canvasTexture = new CanvasTexture(wasmContext, width, height);
canvasTexture.clear();

// do some drawing with html5Context
const html5Context = canvasTexture.getContext();
// todo - your drawing here

// Copy and get the texture
canvasTexture.copyTexture();
const webAssemblyTexture: TSRTexture = canvasTexture.getTexture();

// After use, delete the CanvasTexture
canvasTexture.delete();

Hierarchy

Implements

Index

Constructors

constructor

Properties

canvas

canvas: HTMLCanvasElement

Readonly height

height: number

Readonly width

width: number

Methods

applyOpacity

  • applyOpacity(opacity: number): void
  • Parameters

    • opacity: number

    Returns void

clear

  • clear(): void
  • Clears the texture and the canvas

    Returns void

copyTexture

  • copyTexture(): void
  • After you have finished drawing, copy the canvas to the destination {@link TSRTexture}

    Returns void

delete

  • delete(): void
  • Deletes native (WebAssembly) memory used by this type, after which it cannot be used.

    remarks

    Call .delete() before finishing with the object to ensure that WebAssmembly memory leaks do not occur.

    All elements within SciChart's High Performance Realtime JavaScript Charts which implement IDeletable must be deleted manually to free native (WebAssembly) memory

    Returns void

getContext

  • getContext(): CanvasRenderingContext2D
  • Get an HTML5 {@link CanvasRenderingContext2D} to draw on.

    Returns CanvasRenderingContext2D

getTexture

  • getTexture(): TSRTexture
  • Get the SciChart WebAssembly / WebGL {@link TSRTexture | Texture}

    Returns TSRTexture

Generated using TypeDoc