4 getPoints = function(x, y, angle, width, length) {
7 x: x + Math.cos(angle + Math.PI / 2) * width / 2,
8 y: y + Math.sin(angle + Math.PI / 2) * width / 2
10 x: x + Math.cos(angle) * length,
11 y: y + Math.sin(angle) * length
13 x: x + Math.cos(angle - Math.PI / 2) * width / 2,
14 y: y + Math.sin(angle - Math.PI / 2) * width / 2
19 drawToCanvas: function(ctx, x, y, angle, width, color, length) {
24 length = length || width;
25 ctx.fillStyle = color;
27 ctx.strokeStyle = 'transparent';
29 points = getPoints(x, y, angle, width, length);
30 ctx.moveTo(points[0].x, points[0].y);
31 ctx.lineTo(points[1].x, points[1].y);
32 ctx.lineTo(points[2].x, points[2].y);
35 svg: function(x, y, angle, width, color, length) {
40 length = length || width;
41 points = getPoints(x, y, angle, width, length);
42 return "<polygon fill='" + color + "' stroke='none' points='" + (points.map(function(p) {
43 return p.x + "," + p.y;