Paint
Make drawings, animations, and games with Gleam!
Paint is a tiny embedded domain specific language (inspired by Gloss). Make pictures out of basic shapes then style, transform, and combine them using the provided functions.
import paint
fn main() {
let my_picture = paint.combine([
paint.circle(50.0),
paint.circle(30.0) |> paint.fill(paint.color_rgb(0, 200, 200)),
paint.rectangle(100.0, 50.0) |> paint.rotate(angle_deg(30.0)),
paint.text("Hello world", 20) |> paint.translate_y(-65.0),
])
paint.display_on_canvas(fn(_canvas_config) { my_picture }, "canvas_id")
}
Want to learn more? Read the docs or browse the visual examples.
Currently, there is only a HTML canvas backend for displaying the pictures. Hopefully, I will have time to add other backends in the future (such as SVG). Feel free to contribute!
TODOs
-
I’m not super happy with the API for the transformations. The functions
scale,translate, androtateall affect the same underlying transformation matrix. This means that the order in which these functions are applied greatly matter. Maybe I could normalize the Picture tree before drawing? Or introduce an API more similar to Haskell diagrams and Diagrammer. - Add more utility functions (especially for parsing color formats)
- Support (bitmap) images
- Add another backend