| 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
 | | /** |  |  * 心形 |  |  */ |  |   |  | import Path, { PathProps } from '../Path'; |  |   |  | export class HeartShape { |  |     cx = 0 |  |     cy = 0 |  |     width = 0 |  |     height = 0 |  | } |  |   |  | export interface HeartProps extends PathProps { |  |     shape?: Partial<HeartShape> |  | } |  | class Heart extends Path<HeartProps> { |  |   |  |     shape: HeartShape |  |   |  |     constructor(opts?: HeartProps) { |  |         super(opts); |  |     } |  |   |  |     getDefaultShape() { |  |         return new HeartShape(); |  |     } |  |   |  |     buildPath(ctx: CanvasRenderingContext2D, shape: HeartShape) { |  |         const x = shape.cx; |  |         const y = shape.cy; |  |         const a = shape.width; |  |         const b = shape.height; |  |         ctx.moveTo(x, y); |  |         ctx.bezierCurveTo( |  |             x + a / 2, y - b * 2 / 3, |  |             x + a * 2, y + b / 3, |  |             x, y + b |  |         ); |  |         ctx.bezierCurveTo( |  |             x - a * 2, y + b / 3, |  |             x - a / 2, y - b * 2 / 3, |  |             x, y |  |         ); |  |     } |  | } |  |   |  |   |  | Heart.prototype.type = 'heart'; |  |   |  | export default Heart; | 
 |