Malyan
Construction:
( params : Object )
Create a new instance of Malyan whereparams
is a object with several optional parameters listed below. The constructor also accepts no parameters at all.- id:
String | undefined
the id of the canvas html tag. Optional; defaults toundefined
. - dom:
HTML Element
the HTML element of the canvas. Optional; defaults toundefined
. - width:
Number
the width of the canvas . Optional; defaults to300
. - height:
Number
the height of the canvas . Optional; defaults to150
. - ratio:
Number
the pixel ratio of the canvas. Optional; defaults to1
. - autoRatio:
Boolean
if autoRatio istrue
, the value of ratio will be computed by devicePixelRatio. Optional; defaults totrue
. - autoClear:
Boolean
Defines whether the renderer should automatically clear its output before rendering a frame. Optional; defaults totrue
. - background:
String | undefined
the property of canvas style. Optional; defaults toundefined
.
- id:
Members:
- id:
Number
the same as above - dom:
Number
the same as above - width:
Number
the same as above - height:
Number
the same as above - ratio:
Number
the same as above - autoClear:
Boolean
the same as above - background:
String | undefined
the same as above - ctx:
Object
canvas context - config:
Object
construction arguments (width, height, ratio, autoRatio, autoClear, background...) - scene:
Object
a new instance of Scene - tree:
Object
a new instance of Tree - eventManager:
Object
a 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, ...): null
add 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:
Malyan
the instance of Malyan.
- root:
Members:
- root:
Malyan
the same as above
- root:
Methods:
- render:
(): null
render objects.
- render:
Example:
this.scene = new Scene({ name: 'root_group', root: this })