using System; namespace Orvid.Graphics { public class Colors { public static Pixel Black = new Pixel(0, 0, 0, 0); public static Pixel White = new Pixel(255, 255, 255, 0); } /// /// This class describes a single pixel. /// public class Pixel { /// /// The byte that describes the amount of Red in the pixel. /// public byte R; /// /// The byte that describes the amount of Green in the pixel. /// public byte G; /// /// The byte that describes the amount of Blue in the pixel. /// public byte B; /// /// The byte that describes the transparency of the pixel. /// public byte A; /// /// This tells if the pixel is empty, and should be ignored. /// public bool Empty = false; public Pixel() : this(true) { } public Pixel(byte r, byte g, byte b, byte a) { this.R = r; this.G = g; this.B = b; this.A = a; } public Pixel(bool empty) { if (empty) this.Empty = true; } public static bool operator !=(Pixel a, Pixel b) { if (!(a is Pixel) || !(b is Pixel)) { if (!(a is Pixel) && !(b is Pixel)) return false; return true; } else { if (a.A != b.A || a.B != b.B || a.G != b.G || a.R != b.R) return true; return false; } } public static bool operator !=(Pixel a, int b) { return (a.A != b && a.B != b && a.G != b && a.R != b); } public static bool operator ==(Pixel a, int b) { return (a.A == b && a.B == b && a.G == b && a.R == b); } public static bool operator ==(Pixel a, Pixel b) { if (!(a is Pixel) || !(b is Pixel)) { if (!(a is Pixel) && !(b is Pixel)) return true; return false; } else { if (a.A != b.A || a.B != b.B || a.G != b.G || a.R != b.R) return false; return true; } } public override bool Equals(object obj) { return (this == (Pixel)obj); } public override int GetHashCode() { return 0; } } }