Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. I have the spatial reasoning skills of a spatula (part 2)

I have the spatial reasoning skills of a spatula (part 2)

Scheduled Pinned Locked Moved The Lounge
graphicsdesignagentic-ai
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    honey the codewitch
    wrote on last edited by
    #1

    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 a rect16, 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 method draw::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

    N 1 Reply Last reply
    0
    • H honey the codewitch

      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 a rect16, 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 method draw::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

      N Offline
      N Offline
      Nelek
      wrote on last edited by
      #2

      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.

      H 1 Reply Last reply
      0
      • N Nelek

        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.

        H Offline
        H Offline
        honey the codewitch
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups