Is there a high level crate that creates shapes, kinda like the processing language?

Is there a high level crate that creates shapes based on commands, kinda like the processing language? If so can this be displayed through the xorg server or something?

Maybe this would work for you:

You'd need to combine it yourself with some other library that opens a window and provides a canvas.

1 Like

I'm also interested in something like that.

Did you see Nannou?

That's something I will have a look at.

3 Likes

There is glium_shapes. (but glium is a huge dependency)

There is also plotters and piston. Once the image is generated, you can display it very easily with sdl2. (which is lighter and simpler than glium)

It is possible to generate an SVG then render it with servo, but it wouldn't be the simplest solution.

1 Like

Out of all the libraries you guys have suggested, which one should I use then? I just want to use it to create widgets?

Considering the C dependency, is it really still lighter? I didn't dive into it yet, but I'm interested.

1 Like

I've found piet quite nice to work with in the past.

1 Like

Have you used other libraries? Does piet draw shapes you define (for example you define where the square should be drawn)?

First you'll define your shapes (e.g. kurbo::RoundedRect) then create a RenderContext for your particular platform (piet-cairo for linux, piet-web for a HTML5Canvas in the browser, etc.).

From there you can call methods like RenderContext::stroke() or RenderContext::fill() with that particular shape and a fill style (solid colour, gradient, etc.). Once you've finished painting a frame you'll call finish() to do any finalizing before the image is drawn to the screen.

I've also used the HTML5Canvas directly by compiling my code to WebAssembly, loading it into the browser, then calling various methods on the CanvasRenderingContext2d. It works pretty well, and by running in a browser you don't need to mess around with WinForms/GTK/Qt/whatever.

1 Like

Ah I see, thanks mate :slight_smile:

sdl2 is dynamically linked, so yes, if you already have sdl installed. glium adds about a hundred dependencies that are very long to build.

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.