Library to draw simple shapes

Hello everybody,

I want to draw images with Rust, specifically points, straight and curved lines, rotated ellipses, rendered text, etc. and export the result on PNG.

In the past, in Go, I've used canvas library, in Rust I've tried to use

  • draw but it's not complete (only SVG output),
  • imageproc but doesn't have all the features I need.

Am I missing some other more consolidated library?
Thank you

There's tiny-skia used by resvg.

Thank you!

Tiny-skia doesn't support text rendering (another thing I need - I edited the original post so that now it mentions that).

Maybe I'll just put text generated with imageproc in another transparent layer.

Text rendering is a huge can of worms. The library used by imageproc seems to be deprecated. The alternative is:

piet is a 2D graphics library that wraps various platform specific libraries. It might be sufficient for what you want to do.

Depending on what you want in terms of text, you might like https://crates.io/crates/swash or https://crates.io/crates/parley too. These are from the druid ecosystem.

That second link appears to be broken

Boo. Got that one from the State of the Druid ecosystem post, and parley was listed there with a github repo, which does have the crate name parley, but when I checked the second in lib.rs it timed out. I assumed that was just lib.rs being lib.rs, and edited them both to crates.io, but seems like they just haven't published yet.

Seems from looking at it it's pretty dead, actually... looks like cosmic-text is the current best equivalent? (Though the lib.rs page is... amusing)

I'd like to second piet - I've had great success with it in the past. Something nice is that it supports HTML canvas and SVGs as well as the normal GUI backends.

Thank you everybody!

I think I'll try piet, seems promising!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.