Exemple #1
0
 public static Point FromSize(Size s)
 {
     Point pt;
     pt.X = s.Width;
     pt.Y = s.Height;
     return pt;
 }
Exemple #2
0
 public Rect(Size size)
 {
     this.Origin = Point.Zero;
     this.Size = size;
 }
Exemple #3
0
 public Sprite(byte[] data, int width, int height, Rect? rect = null, bool isRotated = false, Size? unCropSize = null, Point? cropPosition = null)
 {
     this.Texture2D = new Texture2D(Application.SharedApplication.GraphicsDevice, width, height, false, SurfaceFormat.Color);
     this.Texture2D.SetData<byte>(data);
     this.initDefaultProperty(rect, isRotated, unCropSize, cropPosition);
 }
Exemple #4
0
 public Sprite(string assetName, Rect? rect = null, bool isRotated = false, Size? unCropSize = null, Point? cropPosition = null)
 {
     this.Texture2D = Application.SharedApplication.Game.Content.Load<Texture2D>(assetName);
     this.initDefaultProperty(rect, isRotated, unCropSize, cropPosition);
 }
Exemple #5
0
 public Sprite(Texture2D texture2d, Rect? rect = null, bool isRotated = false, Size? unCropSize = null, Point? cropPosition = null)
 {
     this.Texture2D = texture2d;
     this.initDefaultProperty(rect, isRotated, unCropSize, cropPosition);
 }
Exemple #6
0
        private void initDefaultProperty(Rect? rect = null, bool isRotated = false, Size? unCropSize = null, Point? cropPosition = null)
        {
            this.Opacity = 1.0f;
            this.Color = Color.White;

            if (rect == null)
                this.SourceRectangle = new Rect(0, 0, this.Texture2D.Width, this.Texture2D.Height);
            else
                this.SourceRectangle = rect.Value;
            this.IsRotate = isRotated;
            if (unCropSize != null)
                this.UnCropSize = unCropSize.Value;
            if (cropPosition != null)
                this.CropPosition = cropPosition.Value;
        }
Exemple #7
0
 public bool Equals(Size s)
 {
     return Width == s.Width && Height == s.Height;
 }
Exemple #8
0
 public Size Clamp(Size max)
 {
     float w = (this.Width > max.Width) ? max.Width : Width;
     float h = (this.Height > max.Height) ? max.Height : Height;
     return new Size(w, h);
 }
Exemple #9
0
 public static bool Equal(ref Size size1, ref Size size2)
 {
     return ((size1.Width == size2.Width) && (size1.Height == size2.Height));
 }