Canvas_ity: A tiny, single-header <canvas>-like 2D rasterizer for C++ (github.com)

42 points by PaulHoule 5 hours ago

18 comments:

by PaulDavisThe1st 2 minutes ago

And thus random 2D drawing APIs begat Cairo, and then Cairo begat the Canvas, and thus the Canvas begat Canvas_ity, which looked almost like it's grandparent, and yet was very much it's own self.

by nicoburns 4 hours ago

The list of "recommended reading" from one of the issues looks great:

https://github.com/a-e-k/canvas_ity/issues/11#issuecomment-2...

by msephton 2 hours ago

The project is great. The HN comments are embarrassing. Isn’t it ironic to imply laziness by chiming in with “vibe coded” which in itself is such a lazy reaction.

by ddtaylor 2 hours ago

Thank you for sharing. The only thing I don't understand why this is a header only implementation with a macro that goes in a C++ file.

    #define CANVAS_ITY_IMPLEMENTATION
by erwincoumans an hour ago

It is common for header-only libraries: you need to include this header in one c++ using the macro for linking (don't use that macro in other c++ files to avoid duplicate symbols). In C++, you can declare a function as many times as you want, but you can only define it (write the actual body) once in the entire project.

by ddtaylor 25 minutes ago

I understand that part, but I don't see why do this instead of basic Makefile or CMake setup. It seems like more work than a regular linker at that point. For what purpose?

by elteto 15 minutes ago

Because not everyone is using Makefiles or CMake.

A true header-only library should be build-system agnostic and this is one way to do that.

We can argue about build systems for C++ all day long and never come to an agreement. With this approach this piece of code can be used anywhere.

by socalgal2 2 hours ago

that's a common pattern in C++ land because there is no standard way to use libraries in C++

https://github.com/p-ranav/awesome-hpp

by Lerc 3 hours ago

It would be interesting to compile to WASM to compare side by side for performance and accuracy.

by ranger_danger 4 hours ago

vibe-coded?

by nicoburns 4 hours ago

Most likely not seeing as the commit containing the bulk of the implementation dropped in 2022.

by ranger_danger 4 hours ago

maybe just the README then

by flowerbreeze 4 hours ago

The README is older than ChatGPT too. It's very unlikely that it's vibe coded or vibe written.

by peter-m80 3 hours ago

Would that be an issue?

by Amlal 3 hours ago

Yes, it's a canvas library, there's a lot of risks of including AI generated code that hasn't been checked in a rasterizing library.

by ivanjermakov 3 hours ago

A lot of risks compared to what? I imagine bugs in kernel drivers or disk utilities be riskier.

by JoeyJoJoJr 2 hours ago

Such as?

by 1bpp 3 hours ago

Yes.

Data from: Hacker News, provided by Hacker News (unofficial) API