forked from enyojs/canvas
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShape.js
More file actions
42 lines (41 loc) · 1.16 KB
/
Shape.js
File metadata and controls
42 lines (41 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
_enyo.canvas.Shape_ is the base kind for shapes that can be drawn into the
canvas. It 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
/**
Draws the shape by invoking the shape's fill or outline methods,
usually invoked by the derived shape's renderSelf method in response
to the parent of the CanvasControls rendering.
*/
draw: function(inContext) {
if (this.color) {
inContext.fillStyle = this.color;
this.fill(inContext);
}
if (this.outlineColor) {
inContext.strokeStyle = this.outlineColor;
this.outline(inContext);
}
}
});