logo

G

  • Tutorials
  • API
  • Examples
  • Plugins
  • Productsantv logo arrow
  • 6.1.26
  • Canvas
    • Introduction
    • Options
    • Built-in objects
    • Coordinate system
    • Scenegraph & Lifecycle
    • Event
    • OffscreenCanvas & Server-side Rendering
    • CustomElementRegistry
    • Frequently Asked Questions
  • Renderer
    • Introduction
    • Canvas Renderer
    • Canvaskit Renderer
    • SVG Renderer
    • WebGL Renderer
    • WebGPU Renderer
    • Custom Renderer
  • Camera
    • Introduction
    • Camera Parameters
    • Camera action
    • Camera animation
  • Event
    • Introduction
    • Event Object
    • Gesture & Drag'n'Drop
    • Frequently Asked Questions
  • Animation
    • Web Animations API
    • Lottie
  • Basic Shapes
    • Basic Concepts
    • DisplayObject
    • Group
    • Text
    • Circle
    • Ellipse
    • Rect
    • Image
    • Line
    • Polygon
    • Polyline
    • Path
    • HTML
  • Style System
    • Introduction
    • CSS Typed OM
    • Inheritance
    • CSS Properties & Values API
    • CSS Layout API
    • Pattern
    • Gradient
  • 3D
    • 材质
    • 几何
    • Mesh
    • 光源
    • 雾
    • 交互
  • Built-in Objects
    • EventTarget
    • Node
    • Element
    • Document
    • MutationObserver
    • Utils
  • GPGPU
    • Introduction
    • Programming Model
    • Kernel API
    • Principles of classical GPGPU implementation
    • webgpu-graph
  • Declarative programming
    • 使用 Web Components
  • Devtools
    • G 开发者工具
    • 内置的渲染统计信息
    • 第三方开发调试工具

Introduction

Previous
Frequently Asked Questions
Next
Canvas Renderer

Resource

Ant Design
Galacea Effects
Umi-React Application Framework
Dumi-Component doc generator
ahooks-React Hooks Library

Community

Ant Financial Experience Tech
seeconfSEE Conf-Experience Tech Conference

Help

GitHub
StackOverflow

more productsMore Productions

Ant DesignAnt Design-Enterprise UI design language
yuqueYuque-Knowledge creation and Sharing tool
EggEgg-Enterprise-class Node development framework
kitchenKitchen-Sketch Tool set
GalaceanGalacean-Interactive solution
xtechLiven Experience technology
© Copyright 2025 Ant Group Co., Ltd..备案号:京ICP备15032932号-38

Loading...

Renderers use the underlying rendering API to draw various types of graphics. We currently provide the following renderers, which are:

  • g-canvas based on Canvas2D API
  • g-canvaskit based on Canvaskit / Skia
  • g-svg based on SVG
  • g-webgl based on WebGL 2/1
  • g-webgpu based on WebGPU

The renderer consists of a rendering context and a set of plugins that allow the capabilities of the renderer to be dynamically extended at runtime.

Using the g-canvas renderer as an example, the basic usage is as follows.

import { Canvas } from '@antv/g';
import { Renderer } from '@antv/g-canvas';
const canvasRenderer = new Renderer();
const canvas = new Canvas({
container: 'container',
width: 600,
height: 500,
renderer: canvasRenderer,
});

Initial Configuration

When creating a renderer, a series of initialization configurations can be passed in to affect the actual rendering behavior.

enableAutoRendering

Whether to enable auto-rendering or not, the default is on. "Auto-rendering" means that you do not need to manually invoke the rendering method of the canvas, but simply add the graphics to the canvas, which is also consistent with the browser behavior.

It can be turned off for some scenes where the rendering timing needs to be controlled manually.

const webglRenderer = new WebGLRenderer({
enableAutoRendering: false,
});

enableDirtyCheck

Whether to turn on dirty check, default is on. When enabled, only changes in the graphics will trigger canvas redraw.

enableCulling

Whether to turn on view cone culling, off by default. When on, only drawings within the viewport range will be drawn.

Modify configuration

The setConfig allows you to modify the initial configuration, for example to enable automatic rendering again.

renderer.setConfig({ enableAutoRendering: true });

Plug-in related

We provide a number of ways to operate the plug-in.

registerPlugin

Renders can dynamically add plugins at runtime to extend their capabilities, e.g. g-webgl can render 3D scenes via g-pluin-3d.

import { Plugin } from '@antv/g-plugin-3d';
webglRenderer.registerPlugin(new Plugin());

unregisterPlugin

Removal of plug-ins.

renderer.unregisterPlugin(plugin);

getPlugin

Get plugins by name. Each plugin has its own name, and we agree that the name of g-plugin-name is name.

import { Plugin } from '@antv/g-plugin-testonly';
const plugin = new Plugin();
plugin.name; // 'testonly'

So in the renderer it is possible to obtain by plugin name.

renderer.register(plugin);
renderer.getPlugin('testonly'); // plugin

getPlugins

Returns the list of plug-ins for the current renderer.

renderer.getPlugins(); // [Plugin1, Plugin2]