I have the spatial reasoning skills of a toaster oven
-
Halp! I'm lost in rectangles! (not actually a request for help, just a rant) I've got this
draw::image(destination,destination_rectangle,source_image,source_rectangle,&clip_rectangle);
template
gfx_result image_draw_cb(const image_data& data, void* state) {
image_cb_state& s=*(image_cb_state*)state;
if(data.is_fill) {
srect16 sr = *data.fill.bounds;
if(sr.intersects(s.src_rect)) {
if(s.clip!=nullptr) {
sr=sr.crop(s.clip);
}
return draw::filled_rectangle(*s.dst,sr,data.fill.color);
}} return draw::bitmap(\*s.dst,data.bitmap.region->bounds().offset(data.bitmap.location),\*data.bitmap.region,data.bitmap.region->bounds());
}
which is the starting point of what i need but not accurate. Basically i've got several locations and bounds that have to offset and crop each other in order to make image drawing work, and I can't wrap my head around it. I will eventually - I've dealt with worse - a dirty rectangle system in my UI library, but it just frustrates me that thinking in shapes is like a hole in my intellectual abilities. It slows me down, trips me up and makes me struggle.
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
-
Halp! I'm lost in rectangles! (not actually a request for help, just a rant) I've got this
draw::image(destination,destination_rectangle,source_image,source_rectangle,&clip_rectangle);
template
gfx_result image_draw_cb(const image_data& data, void* state) {
image_cb_state& s=*(image_cb_state*)state;
if(data.is_fill) {
srect16 sr = *data.fill.bounds;
if(sr.intersects(s.src_rect)) {
if(s.clip!=nullptr) {
sr=sr.crop(s.clip);
}
return draw::filled_rectangle(*s.dst,sr,data.fill.color);
}} return draw::bitmap(\*s.dst,data.bitmap.region->bounds().offset(data.bitmap.location),\*data.bitmap.region,data.bitmap.region->bounds());
}
which is the starting point of what i need but not accurate. Basically i've got several locations and bounds that have to offset and crop each other in order to make image drawing work, and I can't wrap my head around it. I will eventually - I've dealt with worse - a dirty rectangle system in my UI library, but it just frustrates me that thinking in shapes is like a hole in my intellectual abilities. It slows me down, trips me up and makes me struggle.
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
I was playing with XNA a long time ago and was doing a space thing where multiple transparent images of stars would be stacked to do parallax. The images were screen sized. They would wrap the screen so if the focal point (player) went a pixel left, the far right column of pixels would wrap to the left. This gets more complicated on diagonals. I had to grab a ruler and mark up a physical sheet of paper to work out the code for how to cut the rectangles and glue them back together in real time so that one image could be infinitely scrolled any direction.