It's non-trival though not that hard. Have you asked an LLM?
It depends on your needs
* You can compute a rectangle by expanding a line purpendicular to its direction
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
* 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
This has the issue with the ends will be different unless your brush is round. If that's ok then it works.
All of these are something you can ask Gemini, ChatGPT, Claude, and they'll spit out an exmaple in the language of your choice.
Those are bad answers. Really bad.
What part of them were bad? And where is your contribution?
Asking Gemini spit out this:
https://godbolt.org/z/fzfnY6r39 - using a brush
https://godbolt.org/z/hdKe1b71P - using triangles for miter support.
It's not my responsibility to educate you. Especially if you won't take the time yourself to understand the problem.
I suggest you read through the sibling comments.