MCPcopy
hub / github.com/oblador/react-native-progress / makeSectorPath

Function makeSectorPath

Shapes/Sector.js:7–27  ·  view source on GitHub ↗
(x, y, angle, radius)

Source from the content-addressed store, hash-verified

5const CIRCLE = Math.PI * 2;
6
7function makeSectorPath(x, y, angle, radius) {
8 if (angle >= CIRCLE) {
9 return `M${x} ${y}
10 m${radius} 0
11 a${radius} ${radius} 0 0 1 0 ${radius * 2}
12 a${radius} ${radius} 0 0 1 0 ${radius * -2}`;
13 }
14
15 const startAngle = Math.PI / 2 - angle;
16 const endAngle = Math.PI / 2;
17 const arcFlag = angle > Math.PI ? 1 : 0;
18 const centerX = x + radius;
19 const centerY = y + radius;
20
21 return `M${centerX} ${centerY}
22 L${centerX + Math.cos(startAngle) * radius} ${centerY -
23 Math.sin(startAngle) * radius}
24 A${radius} ${radius} 0 ${arcFlag} 0 ${centerX +
25 Math.cos(endAngle) * radius} ${centerY - Math.sin(endAngle) * radius}
26 L${centerX} ${centerY}`;
27}
28
29export default class Sector extends Component {
30 static propTypes = {

Callers 1

renderMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected