Skip to content

Commit f09131e

Browse files
committed
Snap _candidatesTouching bounds to integer coords
When we construct bounds inside which we should loop over pixels, which is done in _candidatesBounds, we expect their dimensions+position to be integers when looping over them. If they aren't, weird things will occur (e.g. "phantom" touching-color results depending on the precise subpixel bounds position) that are not very fun to debug.
1 parent a7d6368 commit f09131e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/RenderWebGL.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,13 @@ class RenderWebGL extends EventEmitter {
13421342
// Update the CPU position data
13431343
drawable.updateCPURenderAttributes();
13441344
const candidateBounds = drawable.getFastBounds();
1345+
1346+
// Push bounds out to integers. If a drawable extends out into half a pixel, that half-pixel stil
1347+
// needs to be tested. Plus, in some areas we construct another rectangle from the union of these,
1348+
// and iterate over its pixels (width * height). Turns out that doesn't work so well when the
1349+
// width/height aren't integers.
1350+
candidateBounds.snapToInt();
1351+
13451352
if (bounds.intersects(candidateBounds)) {
13461353
result.push({
13471354
id,

0 commit comments

Comments
 (0)