Class Renderer

The main Renderer class with all the rendering function

Hierarchy

  • Renderer

Constructors

Properties

buffers: Buffer[] = []
camera: Camera

The camera to render with

canvas: HTMLCanvasElement

The HTML canvas element

currentBufferIndex: number = 0
currentPath: (null | Vertex)[] = []
gl: WebGL2RenderingContext | WebGLRenderingContext

The WebGL Rendering Context

shaderProgramInfo: ProgramInfo
textRenderer: null | CanvasTextRenderer

The text renderer

transform: Transform

The global transform

vertexColor: Color = ...

The default vertex color

Methods

  • Draws an arc (to the current path). For a circle, set startAngle to 0 and endAngle to Math.PI * 2

    Parameters

    • pos: Vector

      The center of the arc

    • radius: number

      The radius of the arc

    • startAngle: number

      The starting angle of the arc

    • endAngle: number

      The ending angle of the arc

    • detail: number = 1

      The detail of the arc. Higher values = smoother arc. Defaults to 1

    Returns void

  • Starts a new path by clearing everything in the current path. Call this before using any drawing methods.

    Returns void

  • Parameters

    • vertices: Vertex[]
    • width: number
    • closed: boolean = false
    • dashLength: number = 10
    • miterLimit: number

    Returns void

  • Parameters

    • vertices: Vertex[]
    • width: number
    • closed: boolean = false
    • miterLimit: number

    Returns void

  • Clears the screen with the specified color

    Parameters

    • color: Color = ...

      The clear color

    Returns void

  • Enables or disables blending

    Parameters

    • enable: boolean

      Whether to enable or disable blending

    Returns void

  • Fills everything in the current path since the last beginPath() call with the specified color.

    Returns void

  • Parameters

    • text: string

      The text to render

    • pos: Vector

      The position to render the text at

    Returns void

  • Draws a line.

    Parameters

    • startPos: Vector

      Starting position of the line

    • endPos: Vector

      Ending position of the line

    Returns void

  • Draws a rectangle (to the current path). Note that it does not close the path. So if you want to stroke() it, use the closed option in the stroke() method.

    Parameters

    • pos: Vector

      The position of the top left corner of the rectangle

    • size: Vector

      The size (width and height) of the rectangle

    Returns void

  • The main render function. Call this every frame once to render everything.

    Returns void

  • Resizes the canvas to the specified width and height

    Parameters

    • width: number
    • height: number

    Returns void

  • Rotates the camera by the specified angle

    Parameters

    • angle: number

      The angle to rotate the camera by

    Returns void

  • Scales up by the specified vector

    Parameters

    • scale: Vector

      The vector to scale the camera by

    Returns void

  • Scales up by the specified x and y values

    Parameters

    • x: number

      The x value to scale the camera by

    • y: number

      The y value to scale the camera by

    Returns void

  • Scales uniformly by the specified value

    Parameters

    • n: number

      The value to scale the camera by

    Returns void

  • Set Blend Mode

    Parameters

    • blendMode: BlendModes

    Returns void

  • Sets the current buffer to draw to

    Parameters

    • buffer: 0 | Buffer

      The buffer to draw to

    Returns void

  • Sets the default vertex color

    Parameters

    • color: Color

      The color to set

    Returns void

  • Sets the font of the text renderer

    Parameters

    • fontFace: string

      The font to set

    Returns void

    Example

    renderer.setFont("30px Arial");
    
  • Sets the font size of the text renderer

    Parameters

    • fontSize: number

      The font size to set

    Returns void

    Example

    renderer.setFontSize(20);
    
  • Sets the text align of the text renderer

    Parameters

    • spacing: string

    Returns void

    Example

    renderer.setTextAlign("center");
    
  • Sets the text align of the text renderer

    Parameters

    • align: CanvasTextAlign

      The text align to set

    Returns void

    Example

    renderer.setTextAlign("center");
    
  • Sets the text align of the text renderer

    Parameters

    • spacing: string

    Returns void

    Example

    renderer.setTextAlign("center");
    
  • Splits the current path. Call this before using any drawing methods to start a new path without clearing the current one.

    Returns void

  • Strokes (outlines) everything in the current path since the last beginPath() call with the specified width and options.

    Parameters

    • width: number

      The stroke width

    • options: StrokePathOptions = {}

      Options for the stroke

    Returns void

  • Parameters

    • text: string

      The text to render

    • pos: Vector

      The position to render the text at

    • lineWidth: number = 1

    Returns void

  • Translates the camera by the specified vector

    Parameters

    • pos: Vector

      The vector to translate the camera by

    Returns void

  • Translates the camera by the specified x and y values

    Parameters

    • x: number

      The x value to translate the camera by

    • y: number

      The y value to translate the camera by

    Returns void

  • Draws vertices (to the current path).

    Parameters

    Returns void

  • Draws vertices (to the current path).

    Parameters

    Returns void

  • Draws vertices (to the current path).

    Parameters

    • vertices: Vertex[]

      The list of vertices to draw

    Returns void

Generated using TypeDoc