This is the beginning of a new project called "Taffy Canvas". It is to be written in Rust, using Skia: https://github.com/rust-skia/rust-skia
and Taffy as a layout engine: https://github.com/dioxusLabs/taffy
The goal is simple: allow rendering powerful, complex images server-side for message-based games like those on Discord, or open graph images. Having powerful layout capabilities allows focusing more on design than fighting layout, so we want this to be declarative. For simplicity, this should be a simple XML in, image out library.
It will consist of two parts: a rust API/crate, and a wrapper which exposes it to JS/Node.js using napi-rs
It must run with or without GPU (macOS laptops, linux VPSes)
XML will be fairly simple: view, text, image nodes. and support for all CSS layouts that taffy supports (and also: absolute and fixed positions) + styles that are trivial to implement (borders, backgrounds, corner radiuses, etc).
Text measurement should be integrated using Skia itself.
Look into https://github.com/chenglou/pretext this library for inspiration on how to implement flawless image in-line with text layouts.
You must follow test-driven development. Make sure everything is throughly tested including edge cases. What this library renders should be exactly what the layout/XML describes.
For what exactly we're trying to render, look at /Users/dj/Developer/PokeOne/src/engine/hud/
It will have many different kind of images to render.
Essentially, this library should be able to provide an API surface that can:
- provide templating, so you template an HUD once, and just pass in params later and boom it's ready
- support async, off the main thread rendering + pool rendering into different threads so its very fast
What's most important is you must benchmark this. Implement all sorts of performance tricks to make rendering as fast as possible, reuse stuff, etc.