Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove artifact from Polygon rendering #1329

Merged
merged 7 commits into from
May 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add some isclose
  • Loading branch information
hoxbro committed May 8, 2024
commit 0eb9b4e73dcf1ddeb0f7f420df03cdb263ef73ee
9 changes: 6 additions & 3 deletions datashader/glyphs/polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ def draw_polygon(
x1c = x_mapper(x1) * sx + tx - 0.5
y1c = y_mapper(y1) * sy + ty - 0.5

if y1c > y0c:
if np.isclose(y1c, y0c):
# Skip horizontal edges
continue
elif y1c > y0c:
xs[ei, 0] = x0c
ys[ei, 0] = y0c
xs[ei, 1] = x1c
Expand Down Expand Up @@ -199,7 +202,7 @@ def draw_polygon(
# but is kept if upper vertex overlaps
if (
y0c >= yi
# or y1c > yi # Create white dots https://github.com/holoviz/datashader/issues/1327
or y1c < yi
or (x0c < xi and x1c < xi)
hoxbro marked this conversation as resolved.
Show resolved Hide resolved
):
# Edge not eligible for any remaining pixel in this row
Expand All @@ -223,7 +226,7 @@ def draw_polygon(
# Compute cross product of B and A
bxa = (bx * ay - by * ax)

if bxa < 0 or (bxa == 0 and yincreasing[ei]):
if bxa < 0 or (np.isclose(bxa, 0) and yincreasing[ei]):
# Edge to the right
winding_number += yincreasing[ei]
else:
Expand Down