Core
The instance of oCanvas Core that is created using the create() method on the global oCanvas object.
Modules
The core instance contains instances of all the modules in oCanvas.
- animation
- Used for animating things, often short animations triggered as a response to something.
- background
- Used to handle the background of the canvas.
- display
- Contains all the display objects that have been added. Calling
core.display.rectangle(settings)
would return a new rectangle object. - draw
- Handles all of the redrawing of the canvas.
- events
- Handles everything event related, and takes care of the bind() calls.
- keyboard
- Handles all keyboard events.
- mouse
- Handles all mouse events.
- scenes
- Handles different states of your app.
- style
- Handles style related things for internal methods.
- timeline
- Handles the main loop.
- tools
- Tools that other methods use. It is used for finding out if the pointer is inside the objects, which is a must if events are going to work.
- touch
- Handles all touch events.
Methods
- addChild()
- addChildAt() (since version 2.9.0)
- clear()
- destroy() (since version 2.2.0)
- redraw()
- removeChild()
- removeChildAt() (since version 2.9.0)
- reset() (since version 2.2.0)
Properties
- children : Array (since version 2.1.0)
- List of all objects added directly to the core instance.
- height : Number
- The height of the canvas in pixels. Setting this property resizes the canvas and redraws everything.
- id : Number
- The ID of the core instance within the global oCanvas object.
oCanvas.canvasList
is an array of all the instances, so this ID is the index of this instance in that array. - pointer : Object
- Refers to the pointer in use. Touch on touch devices and Mouse otherwise.
- settings : Object
- Object of settings that controls how oCanvas works. Its properties are as follows:
- canvas : String or HTMLCanvasElement
- Specifies the canvas element that oCanvas will work with. Either a CSS selector string, or an HTMLCanvasElement. Note: Can only be set when specified in the settings argument of
oCanvas.create()
.
Required. No default. - background : String
- Sets the background of the canvas to this value. It has to be a string, but accepts all CSS color values, gradients and images (special syntax, see the fill property of display objects). Note: Can only be set when specified in the settings argument of
oCanvas.create()
.
Default: "transparent" - clearEachFrame : Boolean
- Specifies if the timeline module will clear the canvas before each frame or not.
Default: true - drawEachFrame : Boolean
- Specifies if the timeline module will draw the canvas after each frame or not.
Default: true - fps : Number
- The number of frames per second the timeline and animate modules will run at.
Default: 30 - plugins : Array
- Sets which plugins should be used on this core instance. The array contains the plugin names. Note: Can only be set when specified in the settings argument of
oCanvas.create()
.
Default: [] - disableScrolling : Boolean
- Disables scrolling on touch devices. It only disables it on the canvas element, the rest of the page is scrollable. Note: Can only be set when specified in the settings argument of
oCanvas.create()
.
Default: false
- width : Number
- The width of the canvas in pixels. Setting this property resizes the canvas and redraws everything.