-
Notifications
You must be signed in to change notification settings - Fork 0
/
calc.js
34 lines (21 loc) · 847 Bytes
/
calc.js
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
var r = 150;
var alpha = -3.5 * Math.PI / 15;
var x = (r * Math.cos(alpha)).toFixed(2);
var y = (r * Math.sin(alpha)).toFixed(2);
var sx = 0;
var sy = -r;
module.exports.makeSegmentPath = function() {
var result = "";
result += 'M' + sx + ',' + sy + ' A' + r + ',' + r + ' 0 0,1 ' + x + ',' + y + ' ';
//First inside point
var innerRadius = r - 15;
var firstInnerX = (innerRadius * Math.cos(alpha)).toFixed(2);
var firstInnerY = (innerRadius * Math.sin(alpha)).toFixed(2);
result += 'L' + firstInnerX + ',' + firstInnerY + ' ';
//Second inside point
result += 'A' + innerRadius + ',' + innerRadius + ' 0 0,0 0' + (-innerRadius) + ' z';
return result;
};
module.exports.getSegmentRotation = function(segmentIndex) {
return 'rotate (' + (segmentIndex * 360 / 7.5).toFixed(2) + ' 0 0)';
};