I snapped out of my tunnel vision and it feels good.
-
I had been struggling coming up with a common interface for loading images in my graphics library. One method, use by the JPEG decoder for example, is to provide you with a series of small bitmaps to draw until the entire image is rendered. PNG and SVG are different, with PNG being a bit more weird. I've reduced their common functionality to a "fill" function. Instead of a bitmap, you get a color and a rectangle to fill with that color.
struct image_bitmap_data final {
gfx::spoint16 location;
const gfx::const_bitmap>* region;
};
struct image_fill_data final {
const gfx::srect16* bounds;
gfx::rgba_pixel<32> color;
};
struct image_data final {
bool is_fill;
image_bitmap_data bitmap;
image_fill_data fill;
};That's not so bad. It's not my ideal. I'd have liked to use a union for fill_data vs bitmap_data, and is_fill should be "type" and be an enum struct but it made the constructor for the overall type non-trivial so I had to go this route. At any rate, it took me over 24 hours to come up with this, because I was too busy trying to figure out how to break down the functionality using multiple callback methods instead of one that takes a type that itself is hybrid. Tunnel vision is such a time sink. It's my Achilles heel when it comes to coding. I'm normally very fast, even in the design phase, but I get so easily hung up on the simplest decisions because I get myself in an intellectual box. The devil as always, is in the details. 24 hours for about 10 lines of code. meh. It's over now though, and that feels good.
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
-
I had been struggling coming up with a common interface for loading images in my graphics library. One method, use by the JPEG decoder for example, is to provide you with a series of small bitmaps to draw until the entire image is rendered. PNG and SVG are different, with PNG being a bit more weird. I've reduced their common functionality to a "fill" function. Instead of a bitmap, you get a color and a rectangle to fill with that color.
struct image_bitmap_data final {
gfx::spoint16 location;
const gfx::const_bitmap>* region;
};
struct image_fill_data final {
const gfx::srect16* bounds;
gfx::rgba_pixel<32> color;
};
struct image_data final {
bool is_fill;
image_bitmap_data bitmap;
image_fill_data fill;
};That's not so bad. It's not my ideal. I'd have liked to use a union for fill_data vs bitmap_data, and is_fill should be "type" and be an enum struct but it made the constructor for the overall type non-trivial so I had to go this route. At any rate, it took me over 24 hours to come up with this, because I was too busy trying to figure out how to break down the functionality using multiple callback methods instead of one that takes a type that itself is hybrid. Tunnel vision is such a time sink. It's my Achilles heel when it comes to coding. I'm normally very fast, even in the design phase, but I get so easily hung up on the simplest decisions because I get myself in an intellectual box. The devil as always, is in the details. 24 hours for about 10 lines of code. meh. It's over now though, and that feels good.
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
"Much becomes obvious in hindsight, ... Yet it is striking how in both physics and mathematics there is a lack of proportion between the effort needed to understand something for the first time and the simplicity and naturalness of the solution once all the required stages have been completed." - Giorgio Parisi, recipient of the 2021 Nobel Prize in Physics