Thanks to visit codestin.com
Credit goes to programming.dev

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?

  • Matty_r
    Codestin Search App
    Codestin Search App
    Codestin Search App
    3
    ·
    3 days ago

    I’ve been working with Bevy and egui, and have found it pretty nice. At the very least that might help get you started in your research.

  • 0t79JeIfK01RHyzo@lemmy.ml
    Codestin Search App
    Codestin Search App
    English
    Codestin Search App
    7
    ·
    4 days ago

    Since you posted in /c/[email protected], 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.

    • ChocolateFrostedSugarBombs@lemmy.worldOP
      Codestin Search App
      Codestin Search App
      Codestin Search App
      1
      ·
      Codestin Search App
      3 days ago

      Yeah I think i’m leaning more toward the GPU/shader side of things so I’ll take a look at the vulkano-rs and wgpu. I assume vulkano-rs is the rust implementation of the vulcan API?

      And it’s funny you bring up Bevy, I was playing around with the idea of using Bevy or Godot as my wrapper. I have a lot of experience with Unity and I’m pretty comfortable with game engines but I’ve never used Unity ECS nor have I used Godot/Bevy specifically. I do like the idea of making a drawing app with a game engine as impractical as that may be lol.

      I don’t want it limited to the browser. I was more wanting to make a full standalone application to run on the desktop. I also want to incorporate touch and leverage the GPU. So it sounds like vulkano-rs might be the thing to look into.

      EDIT: Forgot to mention that yeah, I’m looking at Rust for now but do you have a recommendation for other programming languages?

  • solrize@lemmy.ml
    Codestin Search App
    Codestin Search App
    Codestin Search App
    8
    ·
    4 days 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.

      • VaxHacker
        Codestin Search App
        Codestin Search App
        Codestin Search App
        3
        ·
        3 days ago

        There are a few basic things you need to sort out first. Keep it as simple as possible so start monochrome, and just add functionality to draw dots on a canvas. You’ll need file handling capability almost immediately so figure out a way to (de-)serialise the information to recreate the artwork to read and write it to a file.

        That’ll keep you going for a few weeks, unless you’re vibing it in which case months by which point you might have had other ideas of features to add, assuming you already know how to write GUI applications.

        • ChocolateFrostedSugarBombs@lemmy.worldOP
          Codestin Search App
          Codestin Search App
          Codestin Search App
          1
          ·
          3 days ago

          Interesting point about monochrome. If I remember correctly though, pixels are rendered with rgba values right? So does monochrome do anything programmatically different than color? Or maybe grayscale does?

          And no, i’m not vibing this…i want to learn how to do this myself and not just regurgitate some hallucinated bullshit.

          I am lacking in how to write GUI applications without using a game engine. I used a lot of Unity with C# and way before that I was using actionscript with Flash lol but other than a handful of WPF apps and WinForms with Powershell I haven’t done straight GUI applications.

          • VaxHacker
            Codestin Search App
            Codestin Search App
            Codestin Search App
            2
            ·
            17 hours ago

            It’s about keeping it simple: black and white only, which of course are RGB(0,0,0) and RGB(255,255,255). If you want to use colours, you need a colour selector which is unnecessary fluff at this point. Obviously it’ll be a critical element fairly soon, but right at the start of the project it’s (arguably of course) less important than the application structure and just getting an MVP together. If you want to do colours before you do File-Open and File-Save that’s a valid choice.

          • IMALlama@lemmy.world
            Codestin Search App
            Codestin Search App
            Codestin Search App
            2
            Codestin Search App
            1
            ·
            3 days ago

            Monochrome just means “a painting, drawing, or photograph in a single hue.” But I think their intent was trying to describe an absolute minimum editor. Think Microsoft paint with the pencil tool but it only draws a single pixel per click.

            Their list of things is fairly reasonable and will result in a fairly long main quests arc. Example. Depending on your familiarity with these items, as well as your familiarity with rust, it could keep you busy for a while in a non-throwaway way.

            I wonder if part of the reason you’re running into a wall is because you’re asking what could be one of many different questions and haven’t provided many hints to help infer intent.

            For example, you could be asking “how do I write a Rust application with a GUI if Rust doesn’t provide out of the box GUI functionality?” In the case you’ll need to use one of the many GUI libraries that are out there. These will let you do screen layout, add buttons, etc.

            You might also be asking, “am I going to have to build my own UI elements, like buttons and menus, from scratch?”. The answer to this is no, unless you want some kind of new/novel UI element. For example, I made a checked list box item in C# about 8 years ago. All the GUI libraries will provide mechanisms to declare and position things like menus and buttons. They’ll also provide hooks to let your application know the user did a thing.

            Finally, you might be asking about how to actually draw/render the picture portion of your graphics editor. The GUI library you choose will significantly impact this. Example. Example. Example. Note that these may or may not be good choices to use.

  • fluxx@lemmy.world
    Codestin Search App
    Codestin Search App
    Codestin Search App
    6
    ·
    4 days 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

    • ChocolateFrostedSugarBombs@lemmy.worldOP
      Codestin Search App
      Codestin Search App
      Codestin Search App
      5
      ·
      4 days ago

      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!