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

Replace embedded-graphics dependency #528

Open
2 of 14 tasks
kpreid opened this issue Sep 21, 2024 · 0 comments
Open
2 of 14 tasks

Replace embedded-graphics dependency #528

kpreid opened this issue Sep 21, 2024 · 0 comments

Comments

@kpreid
Copy link
Owner

kpreid commented Sep 21, 2024

While embedded-graphics has been a useful source of drawing operations, there are disadvantages:

  • In the next release, PixelColor implementers are going to be required to be convertible from bytes which means we'll need to indirect through a palette to draw any blocks that aren't plain color blocks
  • The main reason I originally used it at all was text rendering with built-in fonts, but in the long run I want user-defined fonts, built-in fonts with higher coverage, and 3D text (see Text rendering #424).
  • We still haven't succeeded at fully correct e-g-2D/aic-3D coordinate and bounding box conversion under arbitrary transforms. This is not fundamentally hard; it's just easy to get wrong.
  • Using 2D drawing primitives discourages us from taking advantage of 3D.
  • Aesthetic complaint: Docs get cluttered with all of the blanket traits from az.

Therefore, I believe we should replace e-g. Its current usage is:

  • Rendering:
    • Info text overlay
    • Writing pixels to the image in raytrace_to_texture
  • Text in the world:
    • Evaluating Primitive::Text.
    • Drawing text inside make_some_voxel_blocks() (601910d)
    • Drawing text on demo-city exhibit signs
    • Drawing buttons' text “icons” (af2835d)
    • vui::widgets::LargeText
  • Non-text content:
    • Button widget's base shapes
    • Icons::Delete
    • Colored lights exhibit's test card pattern
    • Copying loaded image assets into blocks.

Migration plan:

  1. Implement raytrace_to_texture directly (perhaps with the help of imgref), without e-g involved.
  2. Change button icon text to be real icons or text labels.
  3. Replace Icons::Delete with an image file.
  4. Replace light test card with an image file.
  5. Replace button shapes with image files.
  6. Use Primitive::Text for make_some_voxel_blocks().
  7. Replace all direct text rendering with Primitive::Text or (for large text) a way to ask our own fonts to draw into a SpaceTransaction or for their pixels (for info text overlay).
  8. Delete (or make private) draw_target() methods.
  9. Replace implementation of text rendering (with what?).
  10. Remove embedded-graphics entirely.

Open questions:

  • Should our new text renderer be from scratch or is there another library that we can use? I don't have notes from the previous library search.
kpreid added a commit that referenced this issue Sep 22, 2024
This removes one of the direct uses of `embedded_graphics`.
See <#528>.

A disadvantage is that now evaluating the block is more expensive. We
could fix that by adding a `BlockDef` wrapper, or by making a way to
turn a `Block` evaluation into the contents of a `Space` (which we'll
probably want someday as an editing tool anyway).
kpreid added a commit that referenced this issue Sep 22, 2024
This removes one of the direct uses of `embedded_graphics`.
See <#528>.
@kpreid kpreid mentioned this issue Sep 22, 2024
17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant