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

Area.union() not computed correctly in some cases #153

Open
FoamyGuy opened this issue Jan 22, 2025 · 0 comments
Open

Area.union() not computed correctly in some cases #153

FoamyGuy opened this issue Jan 22, 2025 · 0 comments

Comments

@FoamyGuy
Copy link
Contributor

FoamyGuy commented Jan 22, 2025

This code:

from displayio._area import Area

area1 = Area(18, 0, 24, 12)
area2 = Area(0, 0, 0, 12)

print(f"area1 = {area1}")
print(f"area2 = {area2}")

area1.union(area2, area1)

print(f"area1 = {area1}")
print(f"area2 = {area2}")

Results in this output:

area1 = Area TL(18,0) BR(24,12)
area2 = Area TL(0,0) BR(0,12)
area1 = Area TL(0,0) BR(0,12)
area2 = Area TL(0,0) BR(0,12)

area1 gets "zero'd out" instead of being modified to contain the full union of the input areas.

This is due to the if statments and early returns here:

if self.empty():
self.copy_into(union)
return
if other.empty():
other.copy_into(union)
return

I don't think that I understand what the original intended purpose of those checks and early returns are but I believe in this case it's causing it to copy the empy area into the union output area which results in the output being smaller than the union of the two inputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant