aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/Rectangle.cs
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2017-08-13 19:11:00 +0200
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2017-08-13 19:11:00 +0200
commitda33782c4ab475d0e8c1216f13ecbff2450ec546 (patch)
treefddb37a0e15ccbb543a3a567e53062630b1fc791 /src/Rectangle.cs
parenta068b75def006a4722d8026f05399bc258ab0d3f (diff)
cairo.region to handle clipping, native pointer leaking...
Diffstat (limited to 'src/Rectangle.cs')
-rw-r--r--src/Rectangle.cs75
1 files changed, 26 insertions, 49 deletions
diff --git a/src/Rectangle.cs b/src/Rectangle.cs
index 574dc3c4..8f48d06d 100644
--- a/src/Rectangle.cs
+++ b/src/Rectangle.cs
@@ -28,73 +28,50 @@ using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
+using System.Runtime.InteropServices;
namespace Crow
-{
+{
+ [StructLayout(LayoutKind.Sequential)]
public struct Rectangle
{
internal static Type TRectangle = typeof(Rectangle);
- #region private fields
- int _x;
- int _y;
- int _width;
- int _height;
- #endregion
+
+ public int X;
+ public int Y;
+ public int Width;
+ public int Height;
#region ctor
- public Rectangle(Point p, Size s)
- {
- _x = p.X;
- _y = p.Y;
- _width = s.Width;
- _height = s.Height;
- }
- public Rectangle(Size s)
+ public Rectangle(Point p, Size s): this (p.X, p.Y, s.Width, s.Height)
+ {
+ }
+ public Rectangle(Size s) : this (0, 0, s.Width, s.Height)
{
- _x = 0;
- _y = 0;
- _width = s.Width;
- _height = s.Height;
}
public Rectangle(int x, int y, int width, int height)
{
- _x = x;
- _y = y;
- _width = width;
- _height = height;
+ X = x;
+ Y = y;
+ Width = width;
+ Height = height;
}
#endregion
#region PROPERTIES
- [XmlIgnore]public int X{
- get { return _x; }
- set { _x = value; }
- }
- [XmlIgnore]public int Y{
- get { return _y; }
- set { _y = value; }
- }
[XmlIgnore]public int Left{
- get { return _x; }
- set { _x = value; }
+ get { return X; }
+ set { X = value; }
}
[XmlIgnore]public int Top{
- get { return _y; }
- set { _y = value; }
+ get { return Y; }
+ set { Y = value; }
}
[XmlIgnore]public int Right{
- get { return _x + _width; }
+ get { return X + Width; }
}
[XmlIgnore]public int Bottom{
- get { return _y + _height; }
- }
- [XmlIgnore]public int Width{
- get { return _width; }
- set { _width = value; }
- }
- [XmlIgnore]public int Height{
- get { return _height; }
- set { _height = value; }
+ get { return Y + Height; }
}
[XmlIgnore]public Size Size{
get { return new Size(Width, Height); }
@@ -253,10 +230,10 @@ namespace Crow
{
int hash = 17;
// Suitable nullity checks etc, of course :)
- hash = hash * 23 + _x.GetHashCode();
- hash = hash * 23 + _y.GetHashCode();
- hash = hash * 23 + _width.GetHashCode();
- hash = hash * 23 + _height.GetHashCode();
+ hash = hash * 23 + X.GetHashCode();
+ hash = hash * 23 + Y.GetHashCode();
+ hash = hash * 23 + Width.GetHashCode();
+ hash = hash * 23 + Height.GetHashCode();
return hash;
}
}