source: node_modules/d3-shape/src/symbol/wye.js

Last change on this file was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Prototype 1.1

  • Property mode set to 100644
File size: 734 bytes
RevLine 
[e4c61dd]1import {sqrt} from "../math.js";
2
3const c = -0.5;
4const s = sqrt(3) / 2;
5const k = 1 / sqrt(12);
6const a = (k / 2 + 1) * 3;
7
8export default {
9 draw(context, size) {
10 const r = sqrt(size / a);
11 const x0 = r / 2, y0 = r * k;
12 const x1 = x0, y1 = r * k + r;
13 const x2 = -x1, y2 = y1;
14 context.moveTo(x0, y0);
15 context.lineTo(x1, y1);
16 context.lineTo(x2, y2);
17 context.lineTo(c * x0 - s * y0, s * x0 + c * y0);
18 context.lineTo(c * x1 - s * y1, s * x1 + c * y1);
19 context.lineTo(c * x2 - s * y2, s * x2 + c * y2);
20 context.lineTo(c * x0 + s * y0, c * y0 - s * x0);
21 context.lineTo(c * x1 + s * y1, c * y1 - s * x1);
22 context.lineTo(c * x2 + s * y2, c * y2 - s * x2);
23 context.closePath();
24 }
25};
Note: See TracBrowser for help on using the repository browser.