Start process of better client-side file locations.
[openemr.git] / public / assets / literallycanvas-0-4-13 / js / core / lineEndCapShapes.js
blobc3885f89357a1ae62c11849009cfafe288df26c8
1 module.exports = {
2   arrow: (function() {
3     var getPoints;
4     getPoints = function(x, y, angle, width, length) {
5       return [
6         {
7           x: x + Math.cos(angle + Math.PI / 2) * width / 2,
8           y: y + Math.sin(angle + Math.PI / 2) * width / 2
9         }, {
10           x: x + Math.cos(angle) * length,
11           y: y + Math.sin(angle) * length
12         }, {
13           x: x + Math.cos(angle - Math.PI / 2) * width / 2,
14           y: y + Math.sin(angle - Math.PI / 2) * width / 2
15         }
16       ];
17     };
18     return {
19       drawToCanvas: function(ctx, x, y, angle, width, color, length) {
20         var points;
21         if (length == null) {
22           length = 0;
23         }
24         length = length || width;
25         ctx.fillStyle = color;
26         ctx.lineWidth = 0;
27         ctx.strokeStyle = 'transparent';
28         ctx.beginPath();
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);
33         return ctx.fill();
34       },
35       svg: function(x, y, angle, width, color, length) {
36         var points;
37         if (length == null) {
38           length = 0;
39         }
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;
44         })) + "' />";
45       }
46     };
47   })()