# Develop Custom Plugins
If you need to add new features to Graphery SVG, it is possible using the gySVG.extend()
method for
adding new capacities for all SVG wrapper objects. It is straightforward to use this extension
way and create new custom plugins.
A custom plugin is a function with two parameters, the first is the Graphery SVG object gySVG
. This object is the
principal constructor and your plugin can add new static methods to this object. The second parameter is the Graphery
SVG wrapper object gySVGObject
and you can extend its prototype for add new method to all Graphery SVG object.
export default function plugin (gySVG, gySVGObject) {
}
This plugin
function is called when the plugin is load to Graphery SVG with gySVG.extend( plugin )
. Commonly, you
can use the Javascript Object.assing()
method for add new method. This is a simple scaffolding than add a static
method .K()
to gySVG
, and a method k()
for all Graphery SVG objects.
export default function plugin (gySVG, gySVGObject) {
Object.assign(gySVG, {
// add new gySVG static methods
K() {
return this;
}
});
Object.assign(gySVGObject.prototype, {
// add new gySVGWrapper methods
k() {
return this;
}
});
}
WARNING
Please, check the return for every method. Only if you return this
the chain of methods is
possible. If you omit this return, it is not possible to call other methods after these calls.
← Sequence