Malyan
Construction:
( params : Object )
Create a new instance of Malyan whereparamsis a object with several optional parameters listed below. The constructor also accepts no parameters at all.- id:
String | undefinedthe id of the canvas html tag. Optional; defaults toundefined. - dom:
HTML Elementthe HTML element of the canvas. Optional; defaults toundefined. - width:
Numberthe width of the canvas . Optional; defaults to300. - height:
Numberthe height of the canvas . Optional; defaults to150. - ratio:
Numberthe pixel ratio of the canvas. Optional; defaults to1. - autoRatio:
Booleanif autoRatio istrue, the value of ratio will be computed by devicePixelRatio. Optional; defaults totrue. - autoClear:
BooleanDefines whether the renderer should automatically clear its output before rendering a frame. Optional; defaults totrue. - background:
String | undefinedthe property of canvas style. Optional; defaults toundefined.
- id:
Members:
- id:
Numberthe same as above - dom:
Numberthe same as above - width:
Numberthe same as above - height:
Numberthe same as above - ratio:
Numberthe same as above - autoClear:
Booleanthe same as above - background:
String | undefinedthe same as above - ctx:
Objectcanvas context - config:
Objectconstruction arguments (width, height, ratio, autoRatio, autoClear, background...) - scene:
Objecta new instance of Scene - tree:
Objecta new instance of Tree - eventManager:
Objecta new instance of EventManager
- id:
Methods:
- getSize:
(): {width: Number, height: Number}
return width and height of canvas. - setSize:
(width: Number, height: Number): null
set width and height of canvas. - getPixelRatio:
(): Number
return current device pixel ratio used. - add:
(object: Object, ...): nulladd one or many shapes / groups to the instance. Objects can be added as arguments, new Malyan().add(o1, o2, oN), or as an array depicted above. - render:
(): null
render a scene. - forEach:
(callback: Function): null
traverse objects Deep First by the way of preOrder.
- getSize:
Example:
var canvas = new Malyan({ id: 'canvas', width: 500, height: 500, background: '#fff })
Scene
Extends: Group
Construction:
( params : Object )
Create a new instance of Scene.- root:
Malyanthe instance of Malyan.
- root:
Members:
- root:
Malyanthe same as above
- root:
Methods:
- render:
(): null
render objects.
- render:
Example:
this.scene = new Scene({ name: 'root_group', root: this })