#region MIT License /*Copyright (c) 2015 Robert Rouhani SharpFont based on Tao.FreeType, Copyright (c) 2003-2007 Tao Framework Team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #endregion using System; using System.Runtime.InteropServices; namespace SharpFont { /// /// A simple structure used to store a 2D vector. /// [StructLayout(LayoutKind.Sequential)] public struct FTVector26Dot6 : IEquatable { #region Fields private IntPtr x; private IntPtr y; #endregion #region Constructors /// /// Initializes a new instance of the struct. /// /// The horizontal coordinate. /// The vertical coordinate. public FTVector26Dot6(Fixed26Dot6 x, Fixed26Dot6 y) : this() { this.x = (IntPtr)x.Value; this.y = (IntPtr)y.Value; } internal FTVector26Dot6(IntPtr reference) : this() { this.x = Marshal.ReadIntPtr(reference); this.y = Marshal.ReadIntPtr(reference, IntPtr.Size); } #endregion #region Properties /// /// Gets or sets the horizontal coordinate. /// public Fixed26Dot6 X { get { return Fixed26Dot6.FromRawValue((int)x); } set { x = (IntPtr)value.Value; } } /// /// Gets or sets the vertical coordinate. /// public Fixed26Dot6 Y { get { return Fixed26Dot6.FromRawValue((int)y); } set { y = (IntPtr)value.Value; } } #endregion #region Operators /// /// Compares two instances of for equality. /// /// A . /// Another . /// A value indicating equality. public static bool operator ==(FTVector26Dot6 left, FTVector26Dot6 right) { return left.Equals(right); } /// /// Compares two instances of for inequality. /// /// A . /// Another . /// A value indicating inequality. public static bool operator !=(FTVector26Dot6 left, FTVector26Dot6 right) { return !left.Equals(right); } #endregion #region Methods /// /// Compares this instance of to another for equality. /// /// A . /// A value indicating equality. public bool Equals(FTVector26Dot6 other) { return x == other.x && y == other.y; } /// /// Compares this instance of to an object for equality. /// /// An object. /// A value indicating equality. public override bool Equals(object obj) { if (obj is FTVector26Dot6) return this.Equals((FTVector26Dot6)obj); else return false; } /// /// Gets a unique hash code for this instance. /// /// A hash code. public override int GetHashCode() { return x.GetHashCode() ^ y.GetHashCode(); } #endregion } }