linebender / bevy_vello

An integration to render with Vello in Bevy game engine.
https://linebender.org/bevy_vello/
Apache License 2.0
117 stars 12 forks source link

Fix render matrix for `VelloScene`s in Bevy UI nodes #59

Closed dannymcgee closed 2 months ago

dannymcgee commented 2 months ago

This PR fixes a couple issues I had when trying to use a VelloScene with Bevy's UI:

  1. The Y-axis was flipped, so that setting any top or bottom value on the Style component caused the VelloScene to move in the opposite direction from the node
  2. Bevy's layout system puts the transform origin at the center of the node's computed bounding box, which is awkward for a canvas-like API where you expect to be issuing draw commands with the origin at the bounding box corner.

That said, I know there are different conventions for whether the Y-origin is top or bottom, and I'm honestly not sure where Vello's origin is under normal circumstances. Let me know if you'd like to preserve a bottom-left origin for Vello drawing commands while still positioning the Vello scene so that it aligns with the Bevy node — it shouldn't be overly difficult to make that adjustment.

I haven't tested this super exhaustively, but I did verify that the original "scene" example still works as expected, and added a new "scene-ui" example for testing the changes made here. Let me know if you have any questions, concerns, or would like to see any changes!

simbleau commented 2 months ago

Thank you for the PR! Please update the CHANGELOG as well with the change.

@seabassjh please review