From f1aee84ef12def83a85056b93b30b2054d6765a3 Mon Sep 17 00:00:00 2001 From: Tim Aidley Date: Thu, 1 Sep 2022 08:22:17 -0700 Subject: [PATCH 1/3] Add Progress Pride flag to pride badge example. Adds the chevrons from the progress pride flag as an option on the Tufty pride flag example. --- micropython/examples/tufty2040/pride_badge.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/micropython/examples/tufty2040/pride_badge.py b/micropython/examples/tufty2040/pride_badge.py index 0e09d4ef..4f59cc18 100644 --- a/micropython/examples/tufty2040/pride_badge.py +++ b/micropython/examples/tufty2040/pride_badge.py @@ -1,6 +1,7 @@ # A name badge with customisable Pride flag background. from picographics import PicoGraphics, DISPLAY_TUFTY_2040 +import math display = PicoGraphics(display=DISPLAY_TUFTY_2040) @@ -31,6 +32,12 @@ COLOUR_ORDER = [RED, ORANGE, YELLOW, GREEN, INDIGO, VIOLET] # traditional pride # COLOUR_ORDER = [MAGENTA, VIOLET, INDIGO] # bi flag # COLOUR_ORDER = [YELLOW, WHITE, AMETHYST, BLACK] # non-binary flag +# Add chevrons to the left +# CHEVRONS = [] # No chevrons +CHEVRONS = [WHITE, PINK, BLUE, BROWN, BLACK] # Progress Pride Flag +# Initial chevron height compared to screen height +FIRST_CHEVRON_HEIGHT = 0.5 + # Change this for vertical stripes STRIPES_DIRECTION = "horizontal" @@ -54,6 +61,17 @@ if STRIPES_DIRECTION == "vertical": for x in range(len(COLOUR_ORDER)): display.set_pen(COLOUR_ORDER[x]) display.rectangle(stripe_width * x, 0, stripe_width, HEIGHT) + +if len(CHEVRONS) > 0: + stripe_width = round((HEIGHT * FIRST_CHEVRON_HEIGHT) / len(CHEVRONS)) + offset = -stripe_width * math.floor((len(CHEVRONS) + 1) / 2) + middle = round(HEIGHT / 2) + for x in range(len(CHEVRONS) -1 ,-1, -1): + display.set_pen(CHEVRONS[x]) + display.triangle( + x * stripe_width + offset, -stripe_width, + (x + 1) * stripe_width + offset + middle, middle, + x * stripe_width + offset, HEIGHT + stripe_width) # Set a starting scale for text size. # This is intentionally bigger than will fit on the screen, we'll shrink it to fit. From 6292d33cdbad7047ec2ff0483cc95ea1cecbb999 Mon Sep 17 00:00:00 2001 From: Tim Aidley Date: Tue, 6 Sep 2022 20:08:12 -0700 Subject: [PATCH 2/3] Fixes to align with flake8 style --- micropython/examples/tufty2040/pride_badge.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/micropython/examples/tufty2040/pride_badge.py b/micropython/examples/tufty2040/pride_badge.py index 4f59cc18..5d02e366 100644 --- a/micropython/examples/tufty2040/pride_badge.py +++ b/micropython/examples/tufty2040/pride_badge.py @@ -34,7 +34,7 @@ COLOUR_ORDER = [RED, ORANGE, YELLOW, GREEN, INDIGO, VIOLET] # traditional pride # Add chevrons to the left # CHEVRONS = [] # No chevrons -CHEVRONS = [WHITE, PINK, BLUE, BROWN, BLACK] # Progress Pride Flag +CHEVRONS = [WHITE, PINK, BLUE, BROWN, BLACK] # Progress Pride Flag # Initial chevron height compared to screen height FIRST_CHEVRON_HEIGHT = 0.5 @@ -61,12 +61,12 @@ if STRIPES_DIRECTION == "vertical": for x in range(len(COLOUR_ORDER)): display.set_pen(COLOUR_ORDER[x]) display.rectangle(stripe_width * x, 0, stripe_width, HEIGHT) - + if len(CHEVRONS) > 0: stripe_width = round((HEIGHT * FIRST_CHEVRON_HEIGHT) / len(CHEVRONS)) offset = -stripe_width * math.floor((len(CHEVRONS) + 1) / 2) middle = round(HEIGHT / 2) - for x in range(len(CHEVRONS) -1 ,-1, -1): + for x in range(len(CHEVRONS) - 1, -1, -1): display.set_pen(CHEVRONS[x]) display.triangle( x * stripe_width + offset, -stripe_width, From 213e47ffd742ccc7cfd6c76afc1dd2fb0be4a79d Mon Sep 17 00:00:00 2001 From: Tim Aidley Date: Tue, 6 Sep 2022 20:13:16 -0700 Subject: [PATCH 3/3] Fixed chevron size mismatch. I decided I wanted the first chevron a little smaller, and realized I had the sign of the chevron height value reversed. The initial white triangle is now a bit smaller, and the chevron stripes slightly wider. --- micropython/examples/tufty2040/pride_badge.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/micropython/examples/tufty2040/pride_badge.py b/micropython/examples/tufty2040/pride_badge.py index 5d02e366..e6aaee55 100644 --- a/micropython/examples/tufty2040/pride_badge.py +++ b/micropython/examples/tufty2040/pride_badge.py @@ -36,7 +36,7 @@ COLOUR_ORDER = [RED, ORANGE, YELLOW, GREEN, INDIGO, VIOLET] # traditional pride # CHEVRONS = [] # No chevrons CHEVRONS = [WHITE, PINK, BLUE, BROWN, BLACK] # Progress Pride Flag # Initial chevron height compared to screen height -FIRST_CHEVRON_HEIGHT = 0.5 +FIRST_CHEVRON_HEIGHT = 0.4 # Change this for vertical stripes STRIPES_DIRECTION = "horizontal" @@ -63,7 +63,7 @@ if STRIPES_DIRECTION == "vertical": display.rectangle(stripe_width * x, 0, stripe_width, HEIGHT) if len(CHEVRONS) > 0: - stripe_width = round((HEIGHT * FIRST_CHEVRON_HEIGHT) / len(CHEVRONS)) + stripe_width = round((HEIGHT * (1 - FIRST_CHEVRON_HEIGHT)) / len(CHEVRONS)) offset = -stripe_width * math.floor((len(CHEVRONS) + 1) / 2) middle = round(HEIGHT / 2) for x in range(len(CHEVRONS) - 1, -1, -1):