예제 #1
0
        public static RelativeSize operator /(RelativeSize o, float factor)
        {
            RelativeSize loc = new RelativeSize(o, 0);

            loc.Paramater /= factor;
            return(loc);
        }
        public static RelativeSize GetRelativeHeightInAspect(RelativeSize width, float aspectWidth, float aspectHeight)
        {
            RelativeSize height = new RelativeSize();

            height.UseWidth = width.UseWidth;
            if (aspectWidth == 0 || aspectHeight == 0)
            {
                return(height);
            }

            float aspect = aspectWidth / aspectHeight;

            height.Paramater = width.Paramater / aspect;
            return(height);
        }
        public static RelativeSize GetRelativeWidthInAspect(RelativeSize height, float aspectWidth, float aspectHeight)
        {
            RelativeSize width = new RelativeSize();

            width.UseWidth = height.UseWidth;
            if (aspectWidth == 0 || aspectHeight == 0)
            {
                return(width);
            }

            float aspect = aspectWidth / aspectHeight;

            width.Paramater = height.Paramater * aspect;
            return(width);
        }
        public static RelativeSizeXY GetImageRect(string texture, RelativeSize fixedSize, bool useWidth = true)
        {
            RelativeSizeXY size = new RelativeSizeXY();

            TextureInfo info = TextureManager.GetTexture(texture);

            if (info != null && info.PixelSize.X > 0 && info.PixelSize.Y != 0)
            {
                if (useWidth)
                {
                    size.Width  = fixedSize;
                    size.Height = GetRelativeHeightInAspect(fixedSize, info.PixelSize.X, info.PixelSize.Y);
                }
                else
                {
                    size.Width  = GetRelativeWidthInAspect(fixedSize, info.PixelSize.X, info.PixelSize.Y);
                    size.Height = fixedSize;
                }
            }

            return(size);
        }
예제 #5
0
 public virtual void SetSize(RelativeSize w, RelativeSize h)
 {
     Width  = w.Clone();
     Height = h.Clone();
 }
예제 #6
0
 public virtual void Set(RelativeLoc x, RelativeLoc y, RelativeSize w, RelativeSize h, OriginLocation anchor)
 {
     SetLocation(x, y);
     SetSize(w, h);
     AnchorLocation = anchor;
 }
예제 #7
0
 public virtual void Set(RelativeLoc x, RelativeLoc y, RelativeSize w, RelativeSize h)
 {
     SetLocation(x, y);
     SetSize(w, h);
 }
예제 #8
0
 public RelativeRect(RelativeLoc x, RelativeLoc y, RelativeSize w, RelativeSize h, OriginLocation anchor)
 {
     Set(x, y, w, h);
     AnchorLocation = anchor;
 }
예제 #9
0
 public RelativeRect(RelativeLoc x, RelativeLoc y, RelativeSize w, RelativeSize h)
 {
     Set(x, y, w, h);
 }
예제 #10
0
 public RelativeSize(RelativeSize o, float offset)
 {
     Paramater = o.Paramater - offset;
     UseWidth  = o.UseWidth;
     Raw       = o.Raw;
 }
예제 #11
0
 public RelativeSize(RelativeSize o, float offset)
 {
     Paramater = o.Paramater - offset;
     Mode      = o.Mode;
 }
예제 #12
0
 public RelativeSizeXY(Vector2 size)
 {
     Width  = new RelativeSize(size.X);
     Height = new RelativeSize(size.Y);
 }
예제 #13
0
 public RelativeSizeXY(float widht, float height)
 {
     Width  = new RelativeSize(widht);
     Height = new RelativeSize(height);
 }
예제 #14
0
 public RelativeSizeXY(RelativeSize widht, RelativeSize height)
 {
     Width  = widht;
     Height = height;
 }
예제 #15
0
 public static RelativeSize FixedPixelSize(int pixels)
 {
     RelativeSize r = new RelativeSize(); r.Paramater = pixels; r.Raw = true; return(r);
 }
예제 #16
0
 public void Shift(RelativeSize offset)
 {
     Paramater += offset.Paramater;
 }
 public virtual void SetSize(RelativeSize w, RelativeSize h)
 {
     Width  = w;
     Height = h;
 }