@Shadowblitz16 wrote:
can someone tell me why my color class is not being converted correctly to system.drawing.color and back?
I made the class so it would be easier to convert back and forth but it doesn't seem to be drawing things correctly.using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Col1 = Microsoft.Xna.Framework.Color; using Col2 = System.Drawing.Color; namespace XEngine.Classes { /// <summary> /// A class that combines MonoGame.Color and Systsm.Drawing.Color into a single class /// </summary> public class Color { private uint Data = 0; //Hell ya a ton of contructors public Color() { Data = (uint) ( 000 << 24 + 000 << 16 + 000 << 08 + 255 << 00 ); } public Color(uint c) { Data = c; } public Color(Col1 c) { Data = (uint) ( c.R << 24 + c.G << 16 + c.B << 08 + c.A << 00 ); } public Color(Col2 c) { Data = (uint) ( c.R << 24 + c.G << 16 + c.B << 08 + c.A << 00 ); } public Color(Color c) { Data = (uint) ( c.R << 24 + c.G << 16 + c.B << 08 + c.A << 00 ); } public Color(byte r, byte g, byte b, byte a) { Data = (uint) ( r << 24 + g << 16 + b << 08 + a << 00 ); } public uint RGBA { get { return Data; } set { Data = value; } } public byte R { get { return (byte)((Data >> 24) & (int)(0xFF)); } set { Data = (uint)((value << 24) | (int)(Data)); } } public byte G { get { return (byte)((Data >> 16) & (int)(0xFF)); } set { Data = (uint)((value << 16) | (int)(Data)); } } public byte B { get { return (byte)((Data >> 08) & (int)(0xFF)); } set { Data = (uint)((value << 08) | (int)(Data)); } } public byte A { get { return (byte)((Data >> 00) & (int)(0xFF)); } set { Data = (uint)((value << 00) | (int)(Data)); } } public Col1 ToXnaColor() { return new Col1(R,G,B,A); } public Col2 ToSysColor() { return Col2.FromArgb(A,R,G,B); } public void FromXnaColor(Col1 color) { R = color.R; G = color.G; B = color.B; A = color.A; } public void FromSysColor(Col2 color) { R = color.R; G = color.G; B = color.B; A = color.A; } } }
Posts: 2
Participants: 2