14

Hey everyone,

Basically the title. I'd like to learn how to make my own drawing program and I'm slightly surprised that I can't seem to find anything about it. No tutorials or discussions about requirements or just general tutorials.

Does anyone have any recommendations on where I could start?

top 9 comments
sorted by: hot top controversial new old
[-] VaxHacker@programming.dev 2 points 3 hours ago

What kind of drawing? Art or technical?

[-] 0t79JeIfK01RHyzo@lemmy.ml 4 points 12 hours ago

Since you posted in /c/rust@programming.dev, I'll give an answer for Rust.

When thinking about rendering, there are mostly 2 ways to complete it

  1. You handle setting pixels (usually rgba) at x and y coordinates
  2. You use a graphics toolkit that handles rendering commonly used drawing methods. Like rendering circles of a specific size, rendering a line between 2 points, etc.

For 1, the crate pixels provides rendering to x and y coordinates with the CPU to window. If you're doing lots of operations, you'll probably find this too slow, and not fast enough. To solve this problem, people use a GPU instead with shaders. vulkano-rs is a good, wgpu is also good.

For 2, I don't have immediate recommendations, but you can usually find these types of toolkits with game engines. As an example, bevy has an example of rendering shapes.

It also just depends where you want to render. If you're limited to in the browser, you'll find that maybe vulcano won't work, and you'll have to use something like WebGPU instead. Or maybe you're restricted to an environment where a web browser can't be used, so WebGPU can't be used, and Vulkano has to be how you complete it. Maybe you can't use a GPU, and need to render directly to a canvas on web page in the browser, then you can just use the MSDN docs for the canvas. etc.

[-] soulsource@discuss.tchncs.de 1 points 22 minutes ago

For 2) I'd also suggest to check out SDL. There are excellent SDL bindings for Rust, and it's way less involved than dragging in a fully-featured game engine.

[-] solrize@lemmy.ml 7 points 19 hours ago

If you're unfamiliar with PostScript or basic linear algebra, I would start by reading a book or tutorial on PostScript. Not to know how to produce PostScript output, but rather to understand how it handles coordinate transformations. So your drawing program can have nested objects with a transformation for each object, and the transformations compose through the nesting levels. Then you can rotate and scale complicated figures by just changing a single transformation, which is a 2x3 matrix. It's really 3x3 but in "homogenous coordinates" so you only have to store 6 of the numbers.

Obviously, also play with other drawing programs to get ideas for what you want yours to do.

There are also tons of books on computer graphics, though maybe not specifically about drawing programs. The ones I've looked at are way old by now though.

Linear algebra, I was fine in school with but it's been a hot minute since I've had to actually do anything with it and I never did it in the context of programming.

I'll look into PostScript, thanks!

[-] fluxx@lemmy.world 4 points 18 hours ago

It is a very broad topic, you didn't specify what kind of a drawing program you'd want to make. If it's a simple raster drawing, like mspaint used to be, it is not that complicated to make. But complexity quickly adds up - filters, transforms, brushes, layers - it grows in complexity quickly. The easiest GUI in rust I found so far is egui. It provides an immediate mode for drawing graphics that is really simple to grasp very quickly. If it is the best in the long run is questionable, but to get your feet wet - I'd say is perfect

Yeah it's something I'd like to model after more complicated applications with transforms, layer effects, different brushes, etc. but I'm not looking to do that from the get go. At the beginning, probably just more similar to what ms paint used to be.

I'll take a look at egui, thanks!

[-] flamingos@feddit.uk 8 points 20 hours ago

You'll want to decide on a GUI framework to start as you'll have to design quite a bit around it. Rnote is a good place to look, it uses GTK+libadwaita.

Perfect, thanks! I'll take a look at rnote.

I was also considering using a game engine like bevy to see if I could get something interesting going.

this post was submitted on 31 Dec 2025
14 points (100.0% liked)

Rust

7626 readers
70 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 2 years ago
MODERATORS