Esempio n. 1
0
        // Returns coordinates of the start of the image in the
        // floating point range 0..1, and the size as a fraction of
        // the width and height.
        public void UnitCoordStartAndSize(int totalWidth, int totalHeight,
                                          out Vector2 start, out Vector2 size)
        {
            float onePixelWide = 1.0f / (float)totalWidth;
            float onePixelHigh = 1.0f / (float)totalHeight;

            start = new Vector2(((float)left + 0.5f) * onePixelWide,
                                ((float)top + 0.5f) * onePixelHigh);
            size = new Vector2(((float)(Width - 1) + 0.5f) * onePixelWide,
                               ((float)(Height - 1) + 0.5f) * onePixelHigh);
        }
Esempio n. 2
0
 // Returns coordinates of the start of the image in the
 // floating point range 0..1, and the size as a fraction of
 // the width and height.  The return value is true if the
 // named image was found; false otherwise.
 public bool FindImageStartAndSize(string imageName,
                                   out Vector2 start, out Vector2 size)
 {
     foreach (ImageRect rect in imageRects)
     {
         if (rect.name == imageName)
         {
             rect.UnitCoordStartAndSize(width, height, out start, out size);
             return(true);
         }
     }
     start = new Vector2(0f, 0f);
     size  = new Vector2(0f, 0f);
     return(false);
 }
        // Returns coordinates of the start of the image in the
        // floating point range 0..1, and the size as a fraction of
        // the width and height.
        public void UnitCoordStartAndSize(int totalWidth, int totalHeight, 
										  out Vector2 start, out Vector2 size)
        {
            float onePixelWide = 1.0f / (float)totalWidth;
            float onePixelHigh = 1.0f / (float)totalHeight;
            start = new Vector2(((float)left + 0.5f) * onePixelWide,
                                ((float)top + 0.5f) * onePixelHigh);
            size = new Vector2(((float)(Width - 1) + 0.5f) * onePixelWide,
                               ((float)(Height - 1) + 0.5f) * onePixelHigh);
        }
        // Returns coordinates of the start of the image in the
        // floating point range 0..1, and the size as a fraction of
        // the width and height.  The return value is true if the
        // named image was found; false otherwise.
        public bool FindImageStartAndSize(string imageName, 
										   out Vector2 start, out Vector2 size)
        {
            foreach(ImageRect rect in imageRects)
            {
                if (rect.name == imageName)
                {
                    rect.UnitCoordStartAndSize(width, height, out start, out size);
                    return true;
                }
            }
            start = new Vector2(0f, 0f);
            size = new Vector2(0f, 0f);
            return false;
        }