| 46 | } |
| 47 | |
| 48 | buildPath(ctx: CanvasRenderingContext2D, shape: PointerShape) { |
| 49 | const mathCos = Math.cos; |
| 50 | const mathSin = Math.sin; |
| 51 | |
| 52 | const r = shape.r; |
| 53 | const width = shape.width; |
| 54 | let angle = shape.angle; |
| 55 | const x = shape.x - mathCos(angle) * width * (width >= r / 3 ? 1 : 2); |
| 56 | const y = shape.y - mathSin(angle) * width * (width >= r / 3 ? 1 : 2); |
| 57 | |
| 58 | angle = shape.angle - Math.PI / 2; |
| 59 | ctx.moveTo(x, y); |
| 60 | ctx.lineTo( |
| 61 | shape.x + mathCos(angle) * width, |
| 62 | shape.y + mathSin(angle) * width |
| 63 | ); |
| 64 | ctx.lineTo( |
| 65 | shape.x + mathCos(shape.angle) * r, |
| 66 | shape.y + mathSin(shape.angle) * r |
| 67 | ); |
| 68 | ctx.lineTo( |
| 69 | shape.x - mathCos(angle) * width, |
| 70 | shape.y - mathSin(angle) * width |
| 71 | ); |
| 72 | ctx.lineTo(x, y); |
| 73 | } |
| 74 | } |