add()
Add the object to the canvas.
Description
Add the object to the canvas. Also adds the children of the object to canvas. You can also add the object with core.addChild(obj)
, which is more clear as to where the object is added.
Arguments
- redraw : Boolean (since version 2.0.0)
- If set to
false
, the canvas will not be redrawn right after the object is added to canvas. Can be used if you are adding lots of objects at the same time, but only want to redraw once when it's done.
Return Value
displayObject. Returns the display object itself.
Examples
Example 1
We create a new core instance and a rectangle. Then we add the rectangle to the canvas.
View Example
Code
var canvas = oCanvas.create({
canvas: "#canvas",
background: "#ccc"
});
var rectangle = canvas.display.rectangle({
x: 77,
y: 100,
width: 200,
height: 100,
fill: "#000"
});
rectangle.add();
Output