Blame view

node_modules/zrender/src/graphic/shape/Sector.js 1.18 KB
aaac7fed   liuqimichale   add
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
  /**
   * 扇形
   * @module zrender/graphic/shape/Sector
   */
  
  import Path from '../Path';
  import fixClipWithShadow from '../helper/fixClipWithShadow';
  
  export default Path.extend({
  
      type: 'sector',
  
      shape: {
  
          cx: 0,
  
          cy: 0,
  
          r0: 0,
  
          r: 0,
  
          startAngle: 0,
  
          endAngle: Math.PI * 2,
  
          clockwise: true
      },
  
      brush: fixClipWithShadow(Path.prototype.brush),
  
      buildPath: function (ctx, shape) {
  
          var x = shape.cx;
          var y = shape.cy;
          var r0 = Math.max(shape.r0 || 0, 0);
          var r = Math.max(shape.r, 0);
          var startAngle = shape.startAngle;
          var endAngle = shape.endAngle;
          var clockwise = shape.clockwise;
  
          var unitX = Math.cos(startAngle);
          var unitY = Math.sin(startAngle);
  
          ctx.moveTo(unitX * r0 + x, unitY * r0 + y);
  
          ctx.lineTo(unitX * r + x, unitY * r + y);
  
          ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
  
          ctx.lineTo(
              Math.cos(endAngle) * r0 + x,
              Math.sin(endAngle) * r0 + y
          );
  
          if (r0 !== 0) {
              ctx.arc(x, y, r0, endAngle, startAngle, clockwise);
          }
  
          ctx.closePath();
      }
  });