About Store Forum Documentation Contact
Donations:
309$/mo



Post Reply 
Image.drawMask problem
Author Message
phleshdef Offline
Member

Post: #1
Image.drawMask problem
We attempted to make a custom compass type image to go around our mini map. Just like the one used in the tutorial, we used white as our map area color and black as our transparent (color_add) color. We then saved the image as a png and used the converter tool to convert it to a gfx file. For some reason though, the image just doesn't show up at all when we run the game. It doesn't throw an error. It just doesn't appear. Are there some other format considerations we need to be aware of in order for this image to work properly with the Image.drawMask function?
(This post was last modified: 01-31-2013 08:28 AM by phleshdef.)
01-31-2013 08:27 AM
Find all posts by this user Quote this message in a reply
phleshdef Offline
Member

Post: #2
RE: Image.drawMask problem
I'm attaching the .png version of this image to this post along with some sample code (of course the actual image I'm using was converted to gfx using the converter tool.

Code:
void MiniMapWindow::DrawMiniMap(C Rect &rect, C Vec2 &world_center_position, Flt radius)
{
    Vec2 world_min = world_center_position - radius, // minimum coordinates of world position drawn on the mini map
         world_max = world_center_position + radius; // maximum coordinates of world position drawn on the mini map

    Vec2 image_min = Game::World.mini_map.worldToImage(world_min),
         image_max = Game::World.mini_map.worldToImage(world_max),
         image_center = Game::World.mini_map.worldToImage(world_center_position);

    VecI2 image_mini = Floor(image_min), // minimum indexes of used image maps
          image_maxi = Floor(image_max); // maximum indexes of used image maps

    Vec2 image_size = rect.size() / (image_max - image_min); // size of a single map image on the screen

   // iterate through all image maps to be displayed
   for(Int y=image_mini.y; y<=image_maxi.y; y++)
   {
       for(Int x=image_mini.x; x<=image_maxi.x; x++)
       {
            // calculate screen position of the (x,y) image map
            Vec2 image_pos = rect.center() - image_center * image_size;
                 image_pos.x += x * image_size.x;
                 image_pos.y += y * image_size.y;

            // prepare the screen rectangle of the (x,y) image map
            Rect_LD map_image_rect(image_pos, image_size.x, image_size.y);

            // draw the image
            Image &image = Game::World.mini_map(VecI2(x, y)); // access the image map from the world manager
            if(image.is())
            {
                image.drawMask(WHITE, Color(0,0,0,0), map_image_rect, *Images("gfx/MiniMapCompass.gfx"), rect); // if the image map is valid then draw it on the screen using masked drawing
            }
       }
   }

   rect.center().draw(WHITE);
}

   
02-05-2013 02:49 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
RE: Image.drawMask problem
Hi,

You need to draw mini map images with drawMask with mask image having set the alpha channel (check existing mask image from SDK for reference)
After that you can draw your own border/compass using your image from post above, however you need to set alpha channel for it as well (in the image, not through parameters)
02-05-2013 11:51 AM
Find all posts by this user Quote this message in a reply
phleshdef Offline
Member

Post: #4
RE: Image.drawMask problem
Ah, I see. Thank you very much, I'll experiment with that.
02-05-2013 10:25 PM
Find all posts by this user Quote this message in a reply
Post Reply