registerPlugin()

Register a plugin that can be used when creating new core instances.

Syntax registerPlugin(name, plugin)

Return Type undefined

Description

Register a plugin that can be used when creating new core instances. This only adds the plugin to oCanvas, but it doesn't run anything. The plugin is only executed when a core instance is created and the settings for that instance specifies the plugin name.

Arguments

name : String
The name of the plugin. This name is used when creating new core instances that use this plugin.
plugin : Function
A function that contains all the code for your plugin. This code will be executed when oCanvas.create() is called and this plugin is specified in the settings. Inside of this function, this refers to the current core instance.

Return Value

undefined. Doesn't return anything.

Examples

Example 1

We start by creating the plugin function. For simplicity we only let the plugin change the background color to yellow. Then we register the plugin, and finally create a new core instance where we specify the new plugin. When this runs we will get a yellow background instead of the gray background specified in the settings.

View Example
Code
var plugin = function () {
	this.background.set("#ff0");
};

oCanvas.registerPlugin("myPlugin", plugin);

var canvas = oCanvas.create({
	canvas: "#canvas",
	background: "#ccc",
	plugins: ["myPlugin"]
});
Output