public static Point FromSize(Size s) { Point pt; pt.X = s.Width; pt.Y = s.Height; return pt; }
public Rect(Size size) { this.Origin = Point.Zero; this.Size = size; }
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); }
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); }
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); }
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; }
public bool Equals(Size s) { return Width == s.Width && Height == s.Height; }
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); }
public static bool Equal(ref Size size1, ref Size size2) { return ((size1.Width == size2.Width) && (size1.Height == size2.Height)); }