rapid-render
    Preparing search index...

    Class Rapid

    The Rapid class provides a WebGL-based rendering engine.

    Index

    Constructors

    • Constructs a new Rapid instance with the given options.

      Parameters

      • options: IRapidOptions

        Options for initializing the Rapid instance.

      Returns Rapid

    Properties

    backgroundColor: Color
    canvas: HTMLCanvasElement
    devicePixelRatio: number = ...
    gl: WebGLContext
    height: number
    light: LightManager = ...
    matrixStack: MatrixStack = ...
    maxTextureUnits: number
    projection: Float32Array
    projectionDirty: boolean = true
    textures: TextureCache
    tileMap: TileMapRender = ...
    width: number

    Methods

    • Adds a vertex to the current graphic being drawn.

      Parameters

      • offsetX: number

        The X coordinate of the vertex.

      • offsetY: number

        The Y coordinate of the vertex.

      • uv: Vec2

        The texture UV coordinates for the vertex.

      • Optionalcolor: Color

        The color of the vertex. Defaults to the renderer's default color.

      Returns void

    • Clears the canvas with the background color.

      Parameters

      • OptionalbgColor: Color

        The background color to clear the canvas with.

      Returns void

    • Clear the current mask by clearing the stencil buffer. This effectively removes any previously defined mask.

      Returns void

    • Creates a custom shader.

      Parameters

      • vs: string

        Vertex shader code.

      • fs: string

        Fragment shader code.

      • type: ShaderType

        Shader type.

      • textureUnitNum: number = 0

      Returns GLShader

      The created shader object.

    • Draw a mask. Automatically calls startDrawMask.

      Parameters

      • type: MaskType = MaskType.Include

        The type of mask to draw.

      • cb: () => void

        The callback function to execute.

      Returns void

    • Convenience method to render to a Frame Buffer Object Handles starting and ending the FBO rendering automatically

      Parameters

      • fbo: FrameBufferObject

        The Frame Buffer Object to render to

      • cb: () => void

        Callback function containing render commands to execute on the FBO

      Returns void

    • End the mask drawing process. This method configures the WebGL context to use the defined mask for subsequent rendering.

      Returns void

    • Ends rendering to a Frame Buffer Object Restores the default framebuffer and original viewport settings

      Returns void

    • Completes the graphic drawing process and renders the result.

      Returns void

    • Ends the rendering process by rendering the current region.

      Returns void

    • Registers a custom render region with a specified name.

      Parameters

      • name: string

        The name of the region.

      • regionClass: typeof RenderRegion

        The class of the region to register.

      Returns void

    • Render

      Parameters

      • cb: (dt: number) => void

        The function to render.

      Returns void

    • Renders a circle with the specified options.

      Parameters

      • options: ICircleRenderOptions

        The options for rendering the circle, including radius, position, color, and segment count.

      Returns void

    • Renders graphics based on the provided options.

      Parameters

      • options: IGraphicRenderOptions

        The options for rendering the graphic, including points, color, texture, and draw type.

      Returns void

    • Renders a line with the specified options.

      Parameters

      • options: IRenderLineOptions

        The options for rendering the line, including points, color, width, and join/cap types.

      Returns void

    • Renders a rectangle with the specified options.

      Parameters

      • options: IRectRenderOptions

        The options for rendering the rectangle, including width, height, position, and color.

      Returns void

    • Renders a sprite with the specified options.

      Parameters

      • options: ISpriteRenderOptions

        The rendering options for the sprite, including texture, position, color, and shader.

      Returns void

    • Renders a texture directly without additional options. This is a convenience method that calls renderSprite with just the texture.

      Parameters

      • texture: Texture

        The texture to render at the current transformation position.

      Returns void

    • Render a tile map layer.

      Parameters

      • data: (string | number)[][]

        The map data to render.

      • options: TileSet | ILayerRenderOptions

        The options for rendering the tile map layer.

      Returns void

    • Resizes the canvas and updates the viewport and projection matrix.

      Parameters

      • logicalWidth: number
      • logicalHeight: number

      Returns void

    • Restores the matrix state from the stack.

      Returns void

    • Saves the current matrix state to the stack.

      Returns void

    • Set the blend mode for rendering

      Parameters

      Returns void

    • Sets the current render region by name and optionally a custom shader.

      Parameters

      • regionName: string

        The name of the region to set as current.

      • OptionalcustomShader: GLShader

        An optional custom shader to use with the region.

      Returns void

    • Start drawing a mask using the stencil buffer. This method configures the WebGL context to begin defining a mask area.

      Parameters

      Returns void

    • Starts rendering to a Frame Buffer Object (FBO) Sets up the FBO for rendering by binding it, adjusting viewport size and projection

      Parameters

      Returns void

    • Starts the graphic drawing process.

      Parameters

      • options: IGraphicRenderOptions

        The options for the graphic drawing, including shader, texture, and draw type.

      Returns void

    • Starts the rendering process, resetting the matrix stack and clearing the current region.

      Parameters

      • clear: boolean = true

        Whether to clear the matrix stack. Defaults to true.

      Returns number

    • Executes a callback function within a saved and restored matrix state scope.

      Parameters

      • cb: () => void

        The callback function to execute within the saved and restored matrix state scope.

      Returns void