canvas_render
v1.0.6
Published
<dl> <dt><a href="#add">add</a></dt> <dd><p>This function adds objects to the stage</p> </dd> <dt><a href="#destroy">destroy</a></dt> <dd><p>This function destroy an object from the stage</p> </dd> </dl>
Downloads
9
Readme
Members
Functions
add
This function adds objects to the stage
Kind: global variable
destroy
This function destroy an object from the stage
Kind: global variable
| Param | Type | Description | | --- | --- | --- | | name | string | This is the name of the object |
line(start, end, style, stroke)
Takes a vector as start point and another vector as end point of the line
Kind: global function
| Param | Type | Description | | --- | --- | --- | | start | array | This will be the start point of the line | | end | array | This will be the end point of the line | | style | object | This will be the style of the line | | stroke | boolean | If true the line will have an stroke |
poligon(vecs, color, stroke)
This function draws a poligon in the screen
Kind: global function
| Param | Type | Description | | --- | --- | --- | | vecs | array | This contains all the points of the figure | | color | string | This is the color of the poligon | | stroke | boolean | If this true the poligon will have borders |
rect(position, width, height, color)
This function draws a rect in the screen
Kind: global function
| Param | Type | Description | | --- | --- | --- | | position | array | This array contains the coordinates of the rect | | width | number | This is the width of the rect | | height | number | This is the height of the rect | | color | string | This will be the color of the rect |
strokeRect(position, width, height, color, lineWidth)
This function draws the borders of a a rect in the screen
Kind: global function
| Param | Type | Description | | --- | --- | --- | | position | array | This array contains the coordinates of the rect | | width | number | This is the width of the rect | | height | number | This is the height of the rect | | color | string | This will be the color of the rect | | lineWidth | number | This is the width of the line |
text(texto, position, style, stroke)
This function draws a text in the screen
Kind: global function
| Param | Type | Description | | --- | --- | --- | | texto | string | This is the text that will be drawn | | position | array | This array contains the coordinates of the text | | style | object | This object contais the styles of the text | | stroke | boolean | If true the text will have borders |
strokeCircle(position, radius, color, width)
Draws the borders of a circle in the screen
Kind: global function
| Param | Type | Description | | --- | --- | --- | | position | array | This array contains the X and Y coordinates | | radius | number | This will be the radius of the circle | | color | string | This will be the color of the circle | | width | number | This is the width of the line |
circle(position, radius, color)
Draws a circle in the screen
Kind: global function
| Param | Type | Description | | --- | --- | --- | | position | array | This array contains the X and Y coordinates | | radius | number | This will be the radius of the circle | | color | string | This will be the color of the circle |
strokeArc(position, radius, lineWidth, eAngl, aAngl, color)
This function draws the borders of an arc in the screen
Kind: global function
| Param | Type | Description | | --- | --- | --- | | position | array | This array contains the X and Y coordinates | | radius | number | This is the radius of the arc | | lineWidth | number | This is the width of the line | | eAngl | number | This is the end angle | | aAngl | number | This is the start angle | | color | string | This is the color of the arc |
loadImage(name, src)
This function loads an image and saves it.
Kind: global function
| Param | Type | Description | | --- | --- | --- | | name | string | With this name the loaded image will be save in a image cache for later use | | src | string | This is where the image is save |
drawImage(name, position, anchor, rotation, width, height)
This function draws an image on the screen
Kind: global function
| Param | Type | Description | | --- | --- | --- | | name | string | This is the name of the image saved in the imageCache | | position | object | This object contains the position of the image | | anchor | object | This will be the point of rotation of the image | | rotation | number | This will be the rotation of the image | | width | number | This will be the width of the image | | height | number | This will be the height of the image |
SpriteSheet(name, config)
This function renders an animation from an srpite sheet in the screen
Kind: global function
| Param | Type | Description | | --- | --- | --- | | name | string | This will be the name of the animation | | config | object | This object contains the configuration of the animation |
Sprite(name, position, scale, rotation, anchor, src)
This function creates an image object
Kind: global function
| Param | Type | Description | | --- | --- | --- | | name | string | This will be the name of the image | | position | object | This object contains the position of the image | | scale | object | This object contains the scale of the image | | rotation | number | This is the rotation of the image | | anchor | object | This will be the point of rotation of the image | | src | string | This will be the location where the image is saved |
Point(x, y)
This function creates an Point object
Kind: global function
| Param | Type | Description | | --- | --- | --- | | x | number | The X coordinate | | y | number | The Y coordinate |
init(canvasName, width, height)
This function initializes the canvas
Kind: global function
| Param | Type | Description | | --- | --- | --- | | canvasName | string | If this parameter is given the render will try to find a canvas with this ID to draw in | | width | number | This will be the width of the canvas | | height | number | This will be the height of the canvas |
setScale(scale)
This function sets the scale of the canvas to the parameter given
Kind: global function
| Param | Type | Description | | --- | --- | --- | | scale | number | This will be the scale of the canvas |
setStyle(style)
This function puts all the styles given in the context
Kind: global function
| Param | Type | Description | | --- | --- | --- | | style | object | This object contains the styles |
setCenter(vec)
This function translates the context to the coordinates given
Kind: global function
| Param | Type | Description | | --- | --- | --- | | vec | array | This is an array of coordinates |
clear(color)
Clears the entire screen
Kind: global function
| Param | Type | Default | Description | | --- | --- | --- | --- | | color | string | "#000" | With this color the canvas will be clear |
smoth(state)
Enables and disbales canvas smoth
Kind: global function
| Param | Type | Description | | --- | --- | --- | | state | boolean | If true enables canvas smoth and if false disbales canvas smoth |
Stage()
This object contains all that will be render
Kind: global function
update()
This function renders all the objects of the stage
Kind: global function
Graphic(renderFunction, configuration)
This class creates an object that draws in the screen
Kind: global function
| Param | Type | Description | | --- | --- | --- | | renderFunction | function | This function draws in the screen | | configuration | object | This object contais information as the position of where things will be drawn the rotation etc.. |