UNPKG

617 BJavaScriptView Raw
1var Shape = require('./generic');
2
3module.exports = Shape(function(width, height){
4
5 this.width = width;
6 this.height = height;
7
8 var path = this.path;
9
10 if (width < 0){
11 path.move(width, 0);
12 width = -width;
13 }
14 if (height < 0){
15 path.move(0, height);
16 height = -height;
17 }
18
19 if (width < height){
20 var r = width / 2;
21 path.move(0, r)
22 .arc(width, 0, r)
23 .line(0, height - width)
24 .arc(-width, 0, r)
25 .line(0, width - height);
26 } else {
27 var r = height / 2;
28 path.move(r, 0)
29 .line(width - height, 0)
30 .arc(0, height, r)
31 .line(height - width, 0)
32 .arc(0, -height, r);
33 }
34
35 path.close();
36
37});
\No newline at end of file