add very basic copies of System.Drawing classes to Gwen namespace
minimal implementation only, just enough to satisfy Gwen's usage of the original System.Drawing classes
This commit is contained in:
parent
9c705ada09
commit
aceff7ba6c
65
Gwen/Color.cs
Normal file
65
Gwen/Color.cs
Normal file
|
@ -0,0 +1,65 @@
|
|||
using System;
|
||||
|
||||
namespace Gwen
|
||||
{
|
||||
[Serializable]
|
||||
public struct Color
|
||||
{
|
||||
public byte A;
|
||||
public byte R;
|
||||
public byte G;
|
||||
public byte B;
|
||||
|
||||
public static readonly Color White = FromArgb(255, 255, 255);
|
||||
public static readonly Color Black = FromArgb(0, 0, 0);
|
||||
public static readonly Color Red = FromArgb(255, 0, 0);
|
||||
public static readonly Color Green = FromArgb(0, 255, 0);
|
||||
public static readonly Color Blue = FromArgb(0, 0, 255);
|
||||
public static readonly Color Yellow = FromArgb(255, 255, 0);
|
||||
|
||||
public static Color FromArgb(int red, int green, int blue)
|
||||
{
|
||||
return FromArgb(255, red, green, blue);
|
||||
}
|
||||
|
||||
public static Color FromArgb(int alpha, int red, int green, int blue)
|
||||
{
|
||||
Color result;
|
||||
result.A = (byte)alpha;
|
||||
result.R = (byte)red;
|
||||
result.G = (byte)green;
|
||||
result.B = (byte)blue;
|
||||
return result;
|
||||
}
|
||||
|
||||
public float GetHue()
|
||||
{
|
||||
int r = R;
|
||||
int g = G;
|
||||
int b = B;
|
||||
byte minval = (byte) Math.Min (r, Math.Min (g, b));
|
||||
byte maxval = (byte) Math.Max (r, Math.Max (g, b));
|
||||
|
||||
if (maxval == minval)
|
||||
return 0.0f;
|
||||
|
||||
float diff = (float)(maxval - minval);
|
||||
float rnorm = (maxval - r) / diff;
|
||||
float gnorm = (maxval - g) / diff;
|
||||
float bnorm = (maxval - b) / diff;
|
||||
|
||||
float hue = 0.0f;
|
||||
if (r == maxval)
|
||||
hue = 60.0f * (6.0f + bnorm - gnorm);
|
||||
if (g == maxval)
|
||||
hue = 60.0f * (2.0f + rnorm - bnorm);
|
||||
if (b == maxval)
|
||||
hue = 60.0f * (4.0f + gnorm - rnorm);
|
||||
if (hue > 360.0f)
|
||||
hue = hue - 360.0f;
|
||||
|
||||
return hue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
20
Gwen/Point.cs
Normal file
20
Gwen/Point.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
|
||||
namespace Gwen
|
||||
{
|
||||
[Serializable]
|
||||
public struct Point
|
||||
{
|
||||
public int X;
|
||||
public int Y;
|
||||
|
||||
public static readonly Point Empty;
|
||||
|
||||
public Point(int x, int y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
56
Gwen/Rectangle.cs
Normal file
56
Gwen/Rectangle.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
using System;
|
||||
|
||||
namespace Gwen
|
||||
{
|
||||
[Serializable]
|
||||
public struct Rectangle
|
||||
{
|
||||
public int X;
|
||||
public int Y;
|
||||
public int Width;
|
||||
public int Height;
|
||||
|
||||
public static readonly Rectangle Empty;
|
||||
|
||||
public Rectangle(int x, int y, int width, int height)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
public int Left
|
||||
{
|
||||
get
|
||||
{
|
||||
return X;
|
||||
}
|
||||
}
|
||||
|
||||
public int Top
|
||||
{
|
||||
get
|
||||
{
|
||||
return Y;
|
||||
}
|
||||
}
|
||||
|
||||
public int Right
|
||||
{
|
||||
get
|
||||
{
|
||||
return X + Width;
|
||||
}
|
||||
}
|
||||
|
||||
public int Bottom
|
||||
{
|
||||
get
|
||||
{
|
||||
return Y + Height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in a new issue