[–] 7 points 10 months ago (3 children)

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.

  • source
  • [–] [S] 6 points 10 months ago

    I don't know the exact definition of what vibe coding means, other than using Ai. This project exist since 2 years (if not longer) and I use it since a long time now (not regularly, just here and there). It's an amazing tool and by far the best of its type (terminal filemanager) in my opinion. You can look into the code and judge yourself if that is of bad Ai quality. I personally don't care how many emojis they use on their README or website. Using the program itself, I don't see any emojis.

  • source
  • parent
  • context
  • [–] [S] 5 points 10 months 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!

  • source
  • parent
  • context
  • [–] 6 points 10 months ago (1 child)

    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

  • source
  • [–] 8 points 10 months ago (1 child)

    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.

  • source
  • [–] [S] 3 points 10 months ago

    Deku is a declarative binary parser. deku_string is an extension which currently provides utility wrappers for data vectors and unicode strings, which can be prefixed or fixed length. Additionally library provides support for 7-bit encoded integers from .NET.

    For example, I often work with binary structures where strings are either length prefixed (with zero character in a buffer) or in fixed size buffer with a zero-ended sting inside.

    There’s multiple examples with custom writer and reader functions, which work, but are less convenient to use.

    Any additional ideas for utilities are welcome.

  • source
  • parent
  • context
  • [–] 1 point 10 months ago* (last edited 10 months ago)

    NGL that block pattern thing is something I never really noticed but it makes a lot of sense. The messy way to do it in C++ would be with a lambda that you then just evaluate, but being about to avoid that and instead using standard scoping syntax for the same thing neat. I'm pretty sure I've even done this before without even thinking about it.

    And if you put all of the definitions you need right at the top it's super easy to split out into a function if/when you need it elsewhere

  • source
  • [–] 2 points 10 months ago

    I somehow couldn't bear the "self-scratch self-praise" top part of the post, but starting with
    "But the balance is crucial" it was really interesting to read! Contrary to my initial fears, it's not a self-praise post, but actually useful and talks about problems too.

  • source
  • view more: ‹ prev next ›