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
|
| import * as curve from '../core/curve';
|
| /**
| * 三次贝塞尔曲线描边包含判断
| */
| export function containStroke(
| x0: number, y0: number, x1: number, y1: number,
| x2: number, y2: number, x3: number, y3: number,
| lineWidth: number, x: number, y: number
| ): boolean {
| if (lineWidth === 0) {
| return false;
| }
| const _l = lineWidth;
| // Quick reject
| if (
| (y > y0 + _l && y > y1 + _l && y > y2 + _l && y > y3 + _l)
| || (y < y0 - _l && y < y1 - _l && y < y2 - _l && y < y3 - _l)
| || (x > x0 + _l && x > x1 + _l && x > x2 + _l && x > x3 + _l)
| || (x < x0 - _l && x < x1 - _l && x < x2 - _l && x < x3 - _l)
| ) {
| return false;
| }
| const d = curve.cubicProjectPoint(
| x0, y0, x1, y1, x2, y2, x3, y3,
| x, y, null
| );
| return d <= _l / 2;
| }
|
|