I have the spatial reasoning skills of a spatula (part 2)
-
class image {
public:
virtual gfx::gfx_result initialize()=0;
virtual bool initialized() const=0;
virtual void deinitialize()=0;
virtual gfx::size16 dimensions() const=0;
virtual gfx::rect16 bounds() const;
virtual gfx::gfx_result draw(const gfx::rect16& bounds, image_draw_callback callback, void* callback_state=nullptr) const=0;
};The emphasized bit is what vexes me. I had previously had this as an
srect16
, not arect16
, the former being signed while the latter is unsigned. The reason being is when I designed it I stupidly thought it would refer to the destination rectangle where the draw is taking place, not the source rectangle which dictates which part of the image to draw from. So now I've had to change the interface, and all 3 classes to do things differently than they were. Because I finally realized how stupid it was for that to be the destination rectangle. This only after I got to writing the convenience methoddraw::image<>()
which takes both source and destination rectangles. It was at that point that I realized the folly of my design, when I should have seen it a mile off heading into it. I can't think in shapes. I just can't. I am angry at my brain for underperforming in this arena. :thumbsdown: After hours, this is working:// we're within the destination
if((x2>=st.bounds->x1 && x1<=st.bounds->x2) &&
(y2>=st.bounds->y1 && y1<=st.bounds->y2)) {
const int offsx = -st.bounds->x1;
const int offsy = -st.bounds->y1;
const bool left_edge = x2>=st.bounds->x1 && x1x1;
const bool top_edge = y2>=st.bounds->y1 && y1y1;
int xs=0,xpe=w,xc=w;
if(left_edge) {
xs=st.bounds->x1-x1;
xc = w-xs;
}
int ys=0,ype=h,yc=h;
if(top_edge) {
ys=st.bounds->y1-y1;
yc = h-ys;
}
const uint8_t* pbs = (const uint8_t*)bmp;
uint8_t* pbd = ( uint8_t*)st.bmp;
for(int y=0;y> csrc(size16(xc,yc),st.bmp);
data.bitmap.region = &csrc;
data.bitmap.location = point16(x1+offsx,y1+offsy);
gfx_result r =st.cb(da -
class image {
public:
virtual gfx::gfx_result initialize()=0;
virtual bool initialized() const=0;
virtual void deinitialize()=0;
virtual gfx::size16 dimensions() const=0;
virtual gfx::rect16 bounds() const;
virtual gfx::gfx_result draw(const gfx::rect16& bounds, image_draw_callback callback, void* callback_state=nullptr) const=0;
};The emphasized bit is what vexes me. I had previously had this as an
srect16
, not arect16
, the former being signed while the latter is unsigned. The reason being is when I designed it I stupidly thought it would refer to the destination rectangle where the draw is taking place, not the source rectangle which dictates which part of the image to draw from. So now I've had to change the interface, and all 3 classes to do things differently than they were. Because I finally realized how stupid it was for that to be the destination rectangle. This only after I got to writing the convenience methoddraw::image<>()
which takes both source and destination rectangles. It was at that point that I realized the folly of my design, when I should have seen it a mile off heading into it. I can't think in shapes. I just can't. I am angry at my brain for underperforming in this arena. :thumbsdown: After hours, this is working:// we're within the destination
if((x2>=st.bounds->x1 && x1<=st.bounds->x2) &&
(y2>=st.bounds->y1 && y1<=st.bounds->y2)) {
const int offsx = -st.bounds->x1;
const int offsy = -st.bounds->y1;
const bool left_edge = x2>=st.bounds->x1 && x1x1;
const bool top_edge = y2>=st.bounds->y1 && y1y1;
int xs=0,xpe=w,xc=w;
if(left_edge) {
xs=st.bounds->x1-x1;
xc = w-xs;
}
int ys=0,ype=h,yc=h;
if(top_edge) {
ys=st.bounds->y1-y1;
yc = h-ys;
}
const uint8_t* pbs = (const uint8_t*)bmp;
uint8_t* pbd = ( uint8_t*)st.bmp;
for(int y=0;y> csrc(size16(xc,yc),st.bmp);
data.bitmap.region = &csrc;
data.bitmap.location = point16(x1+offsx,y1+offsy);
gfx_result r =st.cb(daQuote:
I have the spatial reasoning skills of a spatula (part 2)
And it is good so... if you had such skills in every topic, what would be left for the rest of us? ;P
M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.
-
Quote:
I have the spatial reasoning skills of a spatula (part 2)
And it is good so... if you had such skills in every topic, what would be left for the rest of us? ;P
M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.
Oh, don't worry. I'm left wanting in several topics. :)
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix