25 using System.Globalization;
26 using System.Runtime.InteropServices;
28 namespace SiliconStudio.Core.Mathematics
35 [StructLayout(LayoutKind.Sequential)]
41 private float _bottom;
60 public RectangleF(
float x,
float y,
float width,
float height)
76 set { _left = value; }
97 get {
return _right; }
98 set { _right = value; }
108 get {
return _bottom; }
109 set { _bottom = value; }
125 _right = value + Width;
143 _bottom = value + Height;
155 get {
return _right - _left; }
156 set { _right = _left + value; }
166 get {
return _bottom - _top; }
167 set { _bottom = _top + value; }
201 return new Vector2(X + (Width / 2), Y + (Height / 2));
215 return (Width == 0.0f) && (Height == 0.0f) && (X == 0.0f) && (Y == 0.0f);
228 return new Size2F(Width, Height);
233 Height = value.Height;
265 Offset(amount.
X, amount.
Y);
272 Offset(amount.
X, amount.
Y);
278 public void Offset(
float offsetX,
float offsetY)
287 public void Inflate(
float horizontalAmount,
float verticalAmount)
289 X -= horizontalAmount;
291 Width += horizontalAmount * 2;
292 Height += verticalAmount * 2;
300 result = (X <= value.X) && (value.X < Right) && (Y <= value.Y) && (value.Y < Bottom);
307 return (X <= value.
X) && (value.Right <= Right) && (Y <= value.
Y) && (value.Bottom <= Bottom);
315 result = (X <= value.X) && (value.Right <= Right) && (Y <= value.Y) && (value.Bottom <= Bottom);
326 return (x >= _left && x <= _right && y >= _top && y <= _bottom);
365 result = (value.X < Right) && (X < value.Right) && (value.Y < Bottom) && (Y < value.Bottom);
377 Intersect(ref value1, ref value2, out result);
387 float newLeft = (value1.X > value2.X) ? value1.X : value2.X;
388 float newTop = (value1.Y > value2.Y) ? value1.Y : value2.Y;
389 float newRight = (value1.Right < value2.Right) ? value1.Right : value2.Right;
390 float newBottom = (value1.Bottom < value2.Bottom) ? value1.Bottom : value2.Bottom;
391 if ((newRight > newLeft) && (newBottom > newTop))
393 result =
new RectangleF(newLeft, newTop, newRight - newLeft, newBottom - newTop);
410 Union(ref value1, ref value2, out result);
422 var left = Math.Min(value1.Left, value2.Left);
423 var right = Math.Max(value1.Right, value2.Right);
424 var top = Math.Min(value1.Top, value2.Top);
425 var bottom = Math.Max(value1.Bottom, value2.Bottom);
426 result =
new RectangleF(left, top, right - left, bottom - top);
438 if (ReferenceEquals(null, obj))
return false;
439 if (obj.GetType() != typeof(
RectangleF))
return false;
446 return MathUtil.NearEqual(other.Left, Left) &&
448 MathUtil.NearEqual(other.Top, Top) &&
462 int result = _left.GetHashCode();
463 result = (result * 397) ^ _top.GetHashCode();
464 result = (result * 397) ^ _right.GetHashCode();
465 result = (result * 397) ^ _bottom.GetHashCode();
478 return left.Equals(right);
489 return !(left == right);
505 return string.Format(CultureInfo.CurrentCulture,
"X:{0} Y:{1} Width:{2} Height:{3}", X, Y, Width, Height);
SiliconStudio.Paradox.Games.Mathematics.Vector2 Vector2
override int GetHashCode()
Returns a hash code for this instance.
float X
Gets or sets the X position.
int X
Gets or sets the X position.
Represents a two dimensional mathematical vector.
static readonly RectangleF Empty
An empty rectangle
static RectangleF Intersect(RectangleF value1, RectangleF value2)
Creates a rectangle defining the area where one rectangle overlaps with another rectangle.
RectangleF(float x, float y, float width, float height)
Initializes a new instance of the RectangleF struct.
void Contains(ref RectangleF value, out bool result)
Determines whether this rectangle entirely contains a specified rectangle.
void Offset(Point amount)
Changes the position of the rectangle.
Structure using the same layout than System.Drawing.SizeF.
bool Contains(Rectangle value)
Determines whether this rectangle entirely contains a specified rectangle.
bool Contains(float x, float y)
Checks, if specified point is inside SharpDX.RectangleF.
_In_ size_t _In_ DXGI_FORMAT _In_ size_t _In_ float size_t y
void Offset(float offsetX, float offsetY)
Changes the position of the rectangle.
void Contains(ref Vector2 value, out bool result)
Determines whether this rectangle contains a specified Point.
float Y
Gets or sets the Y position.
One bounding volume completely contains another.
int Y
Gets or sets the Y position.
override bool Equals(object obj)
Determines whether the specified System.Object is equal to this instance.
float Width
Gets or sets the width.
float Bottom
Gets or sets the bottom.
bool Equals(RectangleF other)
static void Union(ref RectangleF value1, ref RectangleF value2, out RectangleF result)
Creates a new rectangle that exactly contains two other rectangles.
Define a RectangleF. This structure is slightly different from System.Drawing.RectangleF as it is int...
static void Intersect(ref RectangleF value1, ref RectangleF value2, out RectangleF result)
Creates a rectangle defining the area where one rectangle overlaps with another rectangle.
The two bounding volumes overlap.
void Offset(Vector2 amount)
Changes the position of the rectangle.
Structure using the same layout than System.Drawing.Point.
float Y
The Y component of the vector.
bool Contains(Point point)
Checks, if specified SharpDX.Point is inside SharpDX.RectangleF.
float Right
Gets or sets the right.
static RectangleF Union(RectangleF value1, RectangleF value2)
Creates a new rectangle that exactly contains two other rectangles.
System.Windows.Shapes.Rectangle Rectangle
void Inflate(float horizontalAmount, float verticalAmount)
Pushes the edges of the rectangle out by the horizontal and vertical values specified.
float X
The X component of the vector.
override string ToString()
float Height
Gets or sets the height.
static unsafe bool NearEqual(float a, float b)
Checks if a and b are almost equals, taking into account the magnitude of floating point numbers (unl...
Structure using the same layout than System.Drawing.Rectangle
void Intersects(ref RectangleF value, out bool result)
Determines whether a specified rectangle intersects with this rectangle.
bool Intersects(RectangleF value)
Determines whether a specified rectangle intersects with this rectangle.
SiliconStudio.Core.Mathematics.RectangleF RectangleF
bool Contains(Vector2 vector2D)
Checks, if specified SharpDX.Vector2 is inside SharpDX.RectangleF.