diff options
author | Lionel LASKE <llaske@c2s.fr> | 2012-09-18 19:16:20 (GMT) |
---|---|---|
committer | Lionel LASKE <llaske@c2s.fr> | 2012-09-18 19:16:20 (GMT) |
commit | 816de0918c28461cc2d1e3457348fd5b6e11950f (patch) | |
tree | 667959b6e32d998a5bf4ae927ea59d88b71bfd44 /html/lib/canvas/Shape.js |
Initial version
Diffstat (limited to 'html/lib/canvas/Shape.js')
-rw-r--r-- | html/lib/canvas/Shape.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/html/lib/canvas/Shape.js b/html/lib/canvas/Shape.js new file mode 100644 index 0000000..14b0d9a --- /dev/null +++ b/html/lib/canvas/Shape.js @@ -0,0 +1,37 @@ +/** + The base kind for shapes that can be drawn into the canvas. + This doesn't have a default rendering, but an event handler + may call the _draw_ method on it. + + Kinds derived from this one should provide their own implementation of + _renderSelf_. If more complex operations are needed for filled mode or + outline mode, override the _fill_ or _outline_ methods, respectively. +*/ +enyo.kind({ + name: "enyo.canvas.Shape", + kind: enyo.canvas.Control, + published: { + //* Color used to draw the interior of the shape + color: "red", + //* Color used to draw the outline of the shape + outlineColor: "" + }, + //* @protected + fill: function(inContext) { + inContext.fill(); + }, + outline: function(inContext) { + inContext.stroke(); + }, + //* @public + draw: function(inContext) { + if (this.color) { + inContext.fillStyle = this.color; + this.fill(inContext); + } + if (this.outlineColor) { + inContext.strokeStyle = this.outlineColor; + this.outline(inContext); + } + } +}); |