Loading...
In the process of continuous iteration, it is difficult to think through all the features that need to be supported at the beginning of development, and sometimes it is necessary to use the power of the community to continuously produce new feature points or optimize existing features. This requires the system to have a certain degree of scalability. The plug-in pattern is often the approach of choice, with the following advantages.
Plugin systems can be found in a wide range of popular software, such as webpack, VS Code, and Chrome.
To make the rendering engine also well extensible, we also have a built-in plugin system that allows different renderers to extend their capabilities at runtime. The full set of currently supported plugins is listed below.
Extensible plug-in mechanism and rich set of plug-ins:
Import the core and renderer code in UMD format first, then import plugin code in the same way.
<script src="https://unpkg.com/@antv/g-plugin-rough-canvas-renderer@1.7.16/dist/index.umd.min.js"></script>
Then we can use plugin under the namespace window.G
, take g-plugin-rough-canvas-renderer as an example:
const plugin = new window.G.RoughCanvasRenderer.Plugin();
Install core and renderer from NPM first, then we can install plugins in the same way. Take g-plugin-rough-canvas-renderer as an example:
npm install @antv/g-plugin-rough-canvas-renderer --save
Then we can registerPlugin on renderer:
import { Plugin } from '@antv/g-plugin-rough-canvas-renderer';renderer.registerPlugin(new Plugin());
These renderers essentially consist of a set of plug-ins through which their capabilities can also be extended.
renderer.registerPlugin(new Plugin());