frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Ask HN: Need C code for drawing graphic primitives to a framebuffer

2•Surac•7h ago
I have a framebuffer that must be seen as being slow. Also the cpu accessing the fb has no cache whatsoever to accelerate the memory access. I need c code for drawing thick lines with endcaps, thick circles, thick elipsoids and thick beizier curves. I have code to do all this 1 pixel wide, but I need code to draw them with a width without plotting over and over each pixel. I already have Bresenham implementation for lines, circles, ellipsis and beizier

Comments

mfabbri77•7h ago
You need to look at a 2d vector graphics library eg: Skia, Cairo, Agg, NanoVG, Blend2D, OpenVG (and many other, in no particular order).
Surac•6h ago
Thanks. This librarys are so full of features that they literally burry the real drawing part. I had hoped for something more basic. No anti aliasing etc.
mfabbri77•6h ago
You have to look for "stroking": there are several ways to do it, in CPU you usually first perform a piecewise linear approximation of the curve, then offset each segment along the normals, add the caps, get a polygon and draw it.
mathiaspoint•6h ago
You probably want to draw curves and polygons then fill them.

It's possible to imagine drawing extra thick lines by modifying the algorithm but the equivalent changes to a curve would leave gaps. I suppose you could figure out how eg boundary paths for beziers are calculated and transform your algorithm so each step draws to the boundary. It seems like more work for something less general than filling though.