{
return new Color (v.X, v.Y, v.Z, v.W);
}
-
- public static implicit operator System.Drawing.Color(Color c)
- {
- return System.Drawing.Color.FromArgb((int)(c.A * 255), (int)(c.R * 255), (int)(c.G * 255), (int)(c.B * 255));
- }
- public static implicit operator Color(System.Drawing.Color c)
- {
- return new Color (1.0f / c.R, 1.0f / c.G, 1.0f / c.B, 1.0f / c.A);
- }
- public static implicit operator Cairo.Color(Color c)
- {
- return new Cairo.Color(c.R, c.G, c.B, c.A);
- }
public static implicit operator Fill(Color c){
return new SolidColor (c) as Fill;
}
public static bool operator ==(Color left, Color right)
{
- return left.A == right.A &&
- left.R == right.R &&
- left.G == right.G &&
- left.B == right.B ? true : false;
+ return left.A != right.A ? false :
+ left.R != right.R ? false :
+ left.G != right.G ? false :
+ left.B != right.B ? false : true;
}
public static bool operator !=(Color left, Color right)
{
- return left.A == right.A &&
- left.R == right.R &&
- left.G == right.G &&
+ return left.A == right.A ? false :
+ left.R == right.R ? false :
+ left.G == right.G ? false :
left.B == right.B ? false : true;
}
public static bool operator ==(Color c, string n)
{
- return c.Name == n ? true : false;
+ return string.Equals(c.Name, n, StringComparison.Ordinal);
}
public static bool operator !=(Color c, string n)
{
- return c.Name == n ? false : true;
+ return !string.Equals(c.Name, n, StringComparison.Ordinal);
}
public static bool operator ==(string n, Color c)
{
- return c.Name == n ? true : false;
+ return string.Equals (c.Name, n, StringComparison.Ordinal);
}
public static bool operator !=(string n, Color c)
{
- return c.Name == n ? false : true;
+ return !string.Equals (c.Name, n, StringComparison.Ordinal);
}
public static Color operator *(Color c, Double f)
{
{
public static class ExtensionsMethods
{
+ #region Cairo extensions
+ public static void Rectangle(this Cairo.Context ctx, Rectangle r)
+ {
+ ctx.Rectangle (r.X, r.Y, r.Width, r.Height);
+ }
+ public static void SetSourceColor(this Cairo.Context ctx, Color c)
+ {
+ ctx.SetSourceRGBA(c.R,c.G,c.B,c.A);
+ }
+ public static void AddColorStop(this Cairo.Gradient grad, double offset, Color c)
+ {
+ grad.AddColorStop (offset, new Cairo.Color (c.R, c.G, c.B, c.A));
+ }
+ #endregion
public static void Raise(this EventHandler handler, object sender, EventArgs e)
{
if(handler != null)
{
return new System.Drawing.Rectangle(r.X, r.Y, r.Width, r.Height);
}
- public static implicit operator Cairo.Rectangle(Rectangle r)
- {
- return new Cairo.Rectangle((double)r.X, (double)r.Y, (double)r.Width, (double)r.Height);
- }
public static Rectangle operator +(Rectangle r1, Rectangle r2)
{
int x = Math.Min(r1.X, r2.X);