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

PicoVector 2 text word wrap and transform #1027

Conversation

MichaelBell
Copy link
Contributor

A couple of improvements to the PicoVector 2 text support:

  • Add optional max line width (by doing word wrap) and max height arguments to text rendering. These are in pixels, not scaled by font size, but they are scaled (and rotated) if the overall PicoVector transform is not the identity.
  • Apply the overall PicoVector transform to text rendering.

Gadgetoid and others added 30 commits October 31, 2024 11:42
Add preliminary support for multiple layered drawing surfaces.

Allows, for example, static content to be loaded into one layer and
remain unmodified while the above layer contains animations.

Particularly useful for drawing PNG or JPEG UI elements which are
then overdrawn with text or animated elements, without paying the
cost of loading/decoding every frame.
Ignore sign compare and narrowing conversion errors in pretty-poly.h.
Pointers were being incremented as if they were bytes, rather than larger
containers.
pretty-poly.h is not giving us fully clipped rectangles, so revert to the
slower bounds checked pixel for now.
* Remove Polygon types in favour of primitives .circle, .rectangle etc
* Add a new Transform type for building up transformation matrices
* Add support to set/clear transform on drawing
Drop dependence on null terminated strings, and for a final linebreak.

Bound all text processing using the text length.
For both APA102 and WS2812 the pins used on the same PIO must be in the same range.
The GPIO base offset applies to the whole PIO and not individual state machines.

This means that for APA102 both data and clock must be in the same pin range,
ie: either 16-48 inclusive or 0-31 inclusive.
@MichaelBell MichaelBell changed the title PicoVector 2 word wrap and transform PicoVector 2 text word wrap and transform Nov 17, 2024
@@ -51,7 +51,7 @@ int main() {
pp_mat3_translate(&pos, 50, 50);
pp_mat3_rotate(&pos, a);
vector.draw(poly);
vector.text("Hello World", &pos);
vector.text("Hello World", 0, 0, &pos);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatively could make these optional arguments if you prefer - I had kind of forgotten that this was also exposed to C++.

Copy link
Member

Choose a reason for hiding this comment

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

I think it would be good to make these optional, since it also bubbles up to Python. C isn't super helpful about that, though. I wonder if it makes sense to have them part of the text metrics, or if that's just too conceptually weird.

Sensible API design for this has been quite tricky!

//pp_mat3_t t = pp_mat3_identity();
//vector.text("Hello World", {0, 0}, &t);
pp_mat3_t t = pp_mat3_identity();
vector.text("Hello World", 0, 0, &t);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly uncommenting this was unwise as I don't have one of these to test. I got confused between this and the new RP2350 based explorer 😆

@Gadgetoid Gadgetoid force-pushed the feature/picovector2-and-layers branch 2 times, most recently from 633d387 to f4409d8 Compare December 2, 2024 12:15
@Gadgetoid Gadgetoid force-pushed the feature/picovector2-and-layers branch 2 times, most recently from 01d8aa7 to 762c5cb Compare December 4, 2024 16:57
@Gadgetoid
Copy link
Member

Okay I think I merged this into #1019 and forgot. Closing for now and we can deal with any warts as they pop up.

@Gadgetoid Gadgetoid closed this Dec 11, 2024
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.

2 participants