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

implement self hidden property for vectorio shapes #7197

Merged
merged 3 commits into from
Nov 16, 2022

Conversation

FoamyGuy
Copy link
Collaborator

@FoamyGuy FoamyGuy commented Nov 11, 2022

This allows vectorio shapes to be hidden with a property on the objects. Previously the only way to hide them was by putting them into a Group and then hiding the Group. With these changes they can be hidden directly without a parent group.

I used this code for testing the new functionality:

import displayio
import vectorio
import board
from adafruit_display_shapes.circle import Circle
import time

display = board.DISPLAY
main_group = displayio.Group()

palette = displayio.Palette(1)
palette[0] = 0x125690

vec_circle = vectorio.Circle(pixel_shader=palette, radius=25, x=70, y=40)
main_group.append(vec_circle)

rectangle = vectorio.Rectangle(pixel_shader=palette, width=40, height=30, x=155, y=45)
main_group.append(rectangle)

circle = Circle(100, 100, 20, fill=0x00FF00, outline=0xFF00FF)
main_group.append(circle)

points=[(5, 5), (100, 20), (20, 20), (20, 100)]
polygon = vectorio.Polygon(pixel_shader=palette, points=points, x=0, y=0)
main_group.append(polygon)

display.show(main_group)
while True:
    circle.hidden = not circle.hidden
    vec_circle.hidden = not vec_circle.hidden
    rectangle.hidden = not rectangle.hidden
    polygon.hidden = not polygon.hidden
    #print(vec_circle.hidden)
    time.sleep(.5)

Tested the changes successfully on a Feather S2 TFT device.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this! One minor suggestion.

shared-module/vectorio/VectorShape.h Outdated Show resolved Hide resolved
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@tannewt tannewt merged commit 866ff5b into adafruit:main Nov 16, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants