About Store Forum Documentation Contact
Donations:
309$/mo



Post Reply 
Drawing image from ImageAtlas
Author Message
Azriel Offline
Member

Post: #1
Drawing image from ImageAtlas
Hi,
I've just started using Esenthel and I'm pretty newb in programming.
I have a problem with draw function of ImageAtlas.
PHP Code:
void draw(Int part_indexC Vec2 &posFlt pixel_size)C// draw specified part index at 'pos' screen position, with 'pixel_size' 
Everything is fine except position - no matter what vector I pass, it is always drawn at the center of the screen.
Any ideas what I might be doing wrong?
09-24-2015 12:19 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Drawing image from ImageAtlas
Hi!

Thanks for reporting the issue and sorry for the problem, this will be fixed for next release.

This is the correct code:
Code:
void ImageAtlas::draw(Int part_index, C Vec2 &pos, Flt pixel_size)C
{
   if(InRange(part_index, parts))
   {
    C Part &part=parts[part_index];
      if(C Image *image=images.addr(part.image_index))
      {
         Rect_LU screen_rect(part.center_offset*pixel_size+pos,  // position
                             part.trimmed_size *pixel_size    ); // size
         if(part.rotated)image->drawPartVertical(screen_rect, part.tex_rect);
         else            image->drawPart        (screen_rect, part.tex_rect);
      }
   }
}
09-25-2015 12:17 AM
Find all posts by this user Quote this message in a reply
Azriel Offline
Member

Post: #3
RE: Drawing image from ImageAtlas
Yay, works now grin Thanks!
09-25-2015 09:26 AM
Find all posts by this user Quote this message in a reply
Post Reply