|
|
|
@ -436,7 +436,7 @@ function circle_intersects_capsule(ax, ay, bx, by, p1, p2, cx, cy, r) {
@@ -436,7 +436,7 @@ function circle_intersects_capsule(ax, ay, bx, by, p1, p2, cx, cy, r) {
|
|
|
|
|
return dist <= r; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function stroke_intersects_cursor(state, stroke, canvasp, radius) { |
|
|
|
|
function stroke_intersects_capsule(state, stroke, a, b, radius) { |
|
|
|
|
const xs = state.wasm.buffers['xs'].tv.data; |
|
|
|
|
const ys = state.wasm.buffers['ys'].tv.data; |
|
|
|
|
const pressures = state.wasm.buffers['pressures'].tv.data; |
|
|
|
@ -449,8 +449,17 @@ function stroke_intersects_cursor(state, stroke, canvasp, radius) {
@@ -449,8 +449,17 @@ function stroke_intersects_cursor(state, stroke, canvasp, radius) {
|
|
|
|
|
const p1 = pressures[i + 0]; |
|
|
|
|
const p2 = pressures[i + 1]; |
|
|
|
|
|
|
|
|
|
// Test if p1 or p2 overlap the capsule
|
|
|
|
|
if (circle_intersects_capsule(x1, y1, x2, y2, p1 * stroke.width / 255, p2 * stroke.width / 255, a.x, a.y, radius)) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
if (circle_intersects_capsule(x1, y1, x2, y2, p1 * stroke.width / 255, p2 * stroke.width / 255, b.x, b.y, radius)) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (circle_intersects_capsule(x1, y1, x2, y2, p1 * stroke.width / 255, p2 * stroke.width / 255, canvasp.x, canvasp.y, radius)) { |
|
|
|
|
// Lame test for the quad part, only test for line-line intersection
|
|
|
|
|
// TODO: actually test for rotated quad vs circle/rotated quad overlap
|
|
|
|
|
if (segments_intersect(a, b, {'x': x1, 'y': y1}, {'x': x2, 'y': y2})) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|