I had hoped for some more basic stuff. I struggle for 2 months now to implement a fast line draw with width for a embeed cpu. It only has a framebuffer no gpu
The bible of graphics programming, everything with software rendering,<p>"Computer Graphics: Principles and Practice"<p><a href="https://www.informit.com/store/computer-graphics-principles-and-practice-9780321399526" rel="nofollow">https://www.informit.com/store/computer-graphics-principles-...</a><p>Yeah, it is a steep price as many academia books, maybe you can find it on a library nearby, as its first edition was in 1982.
I've used this one:<p><a href="https://gist.github.com/ArminJo/8dc4e61847a693e99bdde919cc7005cc" rel="nofollow">https://gist.github.com/ArminJo/8dc4e61847a693e99bdde919cc70...</a>
<a href="https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm" rel="nofollow">https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm</a>
Fast, thick lines, no gpu<p>Choose 2
It's non-trival though not that hard. Have you asked an LLM?<p>It depends on your needs<p>* You can compute a rectangle by expanding a line purpendicular to its direction<p>The problem with this is you'll get gaps between 2 lines if they are supposed to be connected. You can solve that by trying to connect the corners if the rectangles. Once you do this though you're no longer drawing rectangles. You might have to make a simple triangle rasterizer. Or a scanline rasterizer<p>* You can "drag a brush". You compute a single line, then at each pixel, draw a sprite/circle/rectangle around that pixel. That's slow because you'll draw every pixel more than once but it will work and might be fast enough<p>This has the issue with the ends will be different unless your brush is round. If that's ok then it works.<p>All of these are something you can ask Gemini, ChatGPT, Claude, and they'll spit out an exmaple in the language of your choice.