-
Notifications
You must be signed in to change notification settings - Fork 15
Add Annotation widget #27
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
Conversation
@kmatch98 Well :), I like very much this, makes me remember matplotlib. anyway, testing this with the Cartesian plane, make me rework all the local coordinates, now cartesian widgets respond as a |
Tested in Adafruit CircuitPython 6.2.0-beta.4 on 2021-03-18; Seeeduino Wio Terminal with samd51p19 Testing Codefrom adafruit_displayio_layout.widgets.cartesian import Cartesian
import board
import displayio
from adafruit_display_text import label
from adafruit_bitmap_font import bitmap_font
import terminalio
from adafruit_displayio_layout.widgets.annotation import Annotation
MEDIUM_FONT = bitmap_font.load_font("fonts/Helvetica-Bold-16.bdf")
display = board.DISPLAY
my_group = displayio.Group(max_size=10)
car = Cartesian(x=150,
y=40,
display_color=0x98fb98,
width=100,
height=100,
xrange=(0, 50),
yrange=(0, 50),
subticks=True,
tick_color=0x44FF99,
axes_color=0x990099,
axes_stroke=2,
pointer_color=0xFF4400, )
my_group.append(car)
plane_annotation = Annotation(
widget=car, # positions are relative to the switch
text="widget.bounding_box",
anchor_point=(0.0, 0.0),
# delta_x=2,
text_color=0xFFA500,
)
my_group.append(plane_annotation)
plane_annotation1 = Annotation(
widget=car, # positions are relative to the switch
text="[0,0,150,40]",
anchor_point=(0.0, 0.0),
text_under=True,
text_color=0xFFA500,
)
my_group.append(plane_annotation1)
plane_annotation2 = Annotation(
widget=car, # positions are relative to the switch
text="Origin [0,0] ",
anchor_point=(0.0, 1.0),
delta_y=4,
text_under=False,
text_color=0xFFA500,
)
my_group.append(plane_annotation2)
plot_area = Annotation(
font=MEDIUM_FONT,
widget=car, # positions are relative to the switch
text="Plot Area",
anchor_point=(0.5, 0.5),
position_offset=(-35, 0),
text_under=False,
delta_x=0,
delta_y=0,
line_color=0x00A5FF,
text_color=0x00A5FF,
)
my_group.append(plot_area)
text = "Axes Y"
text_area = label.Label(terminalio.FONT,
text=text,
label_direction="UPR",
x=270,
y=120,
background_color=0xA5CADD,
color=0x6E266E,
)
my_group.append(text_area)
text2 = "Axes X"
text_area2 = label.Label(terminalio.FONT,
text=text2,
x=180,
y=180,
background_color=0xA5CADD,
color=0x6E266E,
)
my_group.append(text_area2)
display.show(my_group)
|
# Conflicts: # docs/api.rst # docs/examples.rst
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this successfully with
Adafruit CircuitPython 6.2.0-beta.4 on 2021-03-18; Adafruit PyPortal with samd51j20
Code looks good to me.
These annotations are really great looking. I like how you allowed it to attach onto another widget. We can use this in future example scripts to highlight the features of new widgets.
Thank you @jposada202020 for testing this out as well.
I’m thinking it will be useful for GUIs that might have a “Help” or “?” Button. Thanks @jposada202020 and @FoamyGuy for reviewing and trying it out and merging! |
And @jposada202020 i like how you did the over and under annotation. I never thought of that! |
Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Shapes to 2.0.8 from 2.0.7: > Merge pull request adafruit/Adafruit_CircuitPython_Display_Shapes#32 from Lukas1337/master > "Increase duplicate code check threshold " Updating https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_Layout to 1.7.0 from 1.6.0: > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_Layout#27 from kmatch98/annotation_PR > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_Layout#26 from kmatch98/dial_rotation Updating https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing to 1.14.1 from 1.14.0: > Merge pull request adafruit/Adafruit_CircuitPython_FeatherWing#69 from jfurcean/expose_cs_pins
Add annotation widget, this allows annotations relative to a widget or freeform.
(I messed up the previous PR, so I am adding it back here.)