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

  • CanvasTexture

Implements

Index

Constructors

constructor

  • new CanvasTexture(webAssemblyContext: TSciChart | TSciChart3D, textureWidth: number, textureHeight: number): CanvasTexture
  • Creates an instance of a CanvasTexture

    remarks

    The CanvasTexture implements IDeletable, and must be manually deleted to free WebAssembly / native memory

    Parameters

    • webAssemblyContext: TSciChart | TSciChart3D

      The {@link TSciChart | SciChart 2D WebAssembly Context} or {@link TSciChart2D | SciChart 2D WebAssembly Context} containing native methods and access to our WebGL2 Engine and WebAssembly numerical methods

    • textureWidth: number

      The width of the texture

    • textureHeight: number

      The height of the texture

    Returns CanvasTexture

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