Skip to content

Commit

Permalink
Add example to Canvas documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jonek authored and tbuschto committed Apr 7, 2015
1 parent 4c76658 commit 5ed621a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions doc/canvas.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Tabris.js Canvas
================

Canvas is a composite which allows the user to draw on it using a canvas context. Canvas context provides a drawing API. It is a subset of the HTML5 [CanvasRenderingContext2D](https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D).
.

To create the canvas context, invoke the following method:

Expand All @@ -14,7 +13,17 @@ tabris.getContext(canvas, width, height);
* width - the width of the drawable area
* height - the height of the drawable area

*Pre-Release Note: This method will likely be moved to the canvas itself.*
Example:

```javascript
tabris.create("Canvas", {
layoutData: {left: 0, top: 0, right: 0, bottom: 0}
}).on("change:bounds", function(canvas, bounds) {
var ctx = tabris.getContext(canvas, bounds.width, bounds.height);
ctx.moveTo(0, 0);
// ...
}).appendTo(page);
```

The following CanvasRenderingContext2D methods are supported:

Expand Down

0 comments on commit 5ed621a

Please sign in to comment.