[Mono-list] new color.cs for inclusion in CVS

Ben Houston ben@exocortex.org
Wed, 6 Mar 2002 19:12:31 -0500


Hi Dennis,

Here's a few quick points if you care...

Should it read "color.a = a;"?
> 		public static Color FromArgb (int a,Color incolor)
> 		{
> 			Color color;
> 			color.a = incolor.a;
> 			color.r = incolor.r;
> 			color.g = incolor.g;
> 			color.b = incolor.b;
> 			return color;
> 		}

Yes, A = 255 implicitly. :-)  At least that's why the MS docs say.
> 		public static Color FromArgb (int r, int g, int b)
> 		{
> 			//TODO: Is 255 the correct value to return for
A?
> 			Color color;
> 			color.a = 255;

I think the following would be a nice addition to the following
function... color.a = ( argpacked & 0xff000000 ) >> 24;
color.r = ( argpacked & 0xff0000 ) >> 16;
color.g = ( argpacked & 0xff00 ) >> 8;
color.b = ( argpacked & 0xff );
> 		public static Color FromArgb (int argpacked)
> 		{
> 			throw new Exception("Not implemented yet");
> 			//TODO: Is 255 the correct value to return for
A?
> 			//TODO: do bit manupulations on packed arg
> 			//return new Color (255, argpacked, argpacked,
> argpacked );
> 		}

I bet you could implement the following pretty nicely using reflection
to find a static field with the name of ColorName and of type Color. :-)
> 		Color FromName(string ColorName)
> 		{
> 			throw new Exception("Not implemented yet");
> 			//return KnownColor(ColorName);
> 		}

You declare the member variables as "int"s and the properties A,R,G,B as
ints.  In the Microsoft version of color these are all "byte"s.  I
believe this is important since their color structure is 4 bytes in size
while yours in 16 bytes in size.
> 		public int A
> 		{
> 			get
> 			{

Kind regards,
-ben houston
4th Year Cognitive Science/Neuroscience
Carleton University, Ottawa, Canada
( ben@exocortex.org / 613-266-0637 )