Options
All
  • Public
  • Public/Protected
  • All
Menu

The WebGlRenderContext2D provides methods for drawing to a WebGL2 / WebAssembly canvas powered by SciChart's Visual Xccelerator engine. This context class is used in SciChart's High Performance Realtime JavaScript Charts to draw shapes, lines, fills, images and more

Hierarchy

  • WebGlRenderContext2D

Implements

Index

Constructors

constructor

  • Creates an instance of the WebGlRenderContext2D

    Parameters

    • webAssemblyContext: TSciChart

      The {@link TSciChart | SciChart WebAssembly Context} containing native methods and access to our WebGL2 Engine

    • viewportSize: Size

      The Viewport Size

    Returns WebGlRenderContext2D

Properties

Readonly viewportSize

viewportSize: Size

Gets the current viewport Size

Static Readonly webGlResourcesRefs

webGlResourcesRefs: Set<ICacheable> = new Set<ICacheable>()

Should store Stores references to all cached WebGlResources ICacheable Is used to invalidate the resources when the WebGL context is lost.

Methods

createPen

  • createPen(stroke: string, strokeThickness: number, strokeDashArray?: number[], antiAliased?: boolean): IPen2D
  • description

    creates a pen (which you should cache) from the provided stroke and strokeThickness

    Parameters

    • stroke: string

      in hex format e.g. #FF6600 or CSS rgba format rgb(255,70,30,0.8)

    • strokeThickness: number

      in pixels

    • Default value strokeDashArray: number[] = []
    • Default value antiAliased: boolean = true

      true if the pen draws an Anti-Aliased linez

    Returns IPen2D

createSolidBrush

  • createSolidBrush(fill: string, opacity?: number): IBrush2D
  • description

    creates a solid color brush (which you should cache) from the provided fillColor and opacity

    Parameters

    • fill: string

      color in hex format, e.g. #FF6600 or CSS rgba format rgb(255,70,30,0.8)

    • Optional opacity: number

      from 0.0 to 1.0

    Returns IBrush2D

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

drawLayers

  • drawLayers(): void
  • Flushes the {@link layers} which have been enqueued with drawing operations in order. Use this in combination with enqueueLayeredDraw to draw in layers

    Returns void

drawLine

  • drawLine(x1: number, y1: number, x2: number, y2: number, pen: IPen2D, viewRect: Rect): void
  • description

    Draws a single line from (x1,y1) to (x2,y2) with the specified Pen

    Parameters

    • x1: number

      The X1 coordinate in pixels

    • y1: number

      The Y1 coordinate in pixels

    • x2: number

      The X2 coordinate in pixels

    • y2: number

      The Y2 coordinate in pixels

    • pen: IPen2D

      the pen to draw with

    • viewRect: Rect

      the series viewRect, used for translate and clipping

    Returns void

drawLines

  • description

    Draws a polyline with the specified Pen

    Parameters

    • xyValues: number[]

      An array of x,y points arranged as x0y0 x1y1 ... xnyn

    • strokePen: IPen2D

      the pen to draw with

    • viewRect: Rect

      the series viewRect, used for translate and clipping

    • Default value lineDrawMode: ELineDrawMode = ELineDrawMode.PolyLine

      whether to draw lines as a polyline, or disconnected lines

    Returns void

drawLinesNative

  • drawLinesNative(vertices: VectorColorVertex, pen: SCRTPen, lineDrawMode: ELineDrawMode, left?: number, top?: number): void
  • Draw lines: grid lines, etc.

    Parameters

    • vertices: VectorColorVertex
    • pen: SCRTPen
    • lineDrawMode: ELineDrawMode
    • Default value left: number = 0

      offset in pixels from left, typically used for axes

    • Default value top: number = 0

      offset in pixels from top, typically used for axes

    Returns void

drawRect

  • description

    Draws a Rect with optional fill and stroke

    Parameters

    • rect: Rect

      the Rect dimensions to draw

    • viewRect: Rect

      the series viewRect, used for translate and clipping

    • Optional strokePen: IPen2D

      the stroke pen to draw the outline with

    • Optional fillBrush: IBrush2D

      the fill brush to draw the fill with

    Returns void

drawRects

  • drawRects(vertices: VectorRectVertex, brush: SCRTBrush, left?: number, top?: number): void
  • Draw rectangles: grid bands, etc.

    Parameters

    • vertices: VectorRectVertex
    • brush: SCRTBrush
    • Default value left: number = 0

      offset in pixels from left, typically used for axes

    • Default value top: number = 0

      offset in pixels from top, typically used for axes

    Returns void

enqueueLayeredDraw

  • Enqueues a draw operation to the specified layer. Use in combination with drawLayers to flush layered draws

    Parameters

    Returns void

getNativeContext

  • getNativeContext(): SCRTRenderContext
  • Get the native {@link SCRTRenderContext} for direct access to SciChart's WebAssembly Visual Xccelerator engine

    Returns SCRTRenderContext

popShaderEffect

  • popShaderEffect(): void
  • Pops a ShaderEffect from the rendering pipeline. Call {@link WebGL2RenderingContext.pushShaderEffect} to apply an effect

    Returns void

printBlendMode

  • printBlendMode(): void
  • Returns void

pushShaderEffect

  • Applies a ShaderEffect to the rendering pipeline. Calling {@link WebGL2RenderingContext.popShaderEffect} pops the effect from the stack reverting to normal drawing

    Parameters

    Returns void

Generated using TypeDoc