File: VertexElementColor.cs

package info (click to toggle)
monogame 2.5.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,060 kB
  • ctags: 10,325
  • sloc: cs: 65,996; xml: 591; makefile: 22; ansic: 8
file content (104 lines) | stat: -rw-r--r-- 2,276 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
using System;

namespace Microsoft.Xna.Framework.Graphics
{
	public struct VertexElementColor
	{
		byte R;
		byte G;
		byte B;
		byte A;

		public VertexElementColor (Color color)
		{

			R = color.R;
			G = color.G;
			B = color.B;
			A = color.A;
		}

		public Color Color {
			get {
				return new Color (R, G, B, A);
			}

			set {
				R = value.R;
				G = value.G;
				B = value.B;
				A = value.A;
			}
		}

		public override string ToString ()
		{
			return string.Format ("[Color: R={0}, G={1}, B={2}, A={3}]", R, G, B, A);
		}

		public static implicit operator Color (VertexElementColor typ)
		{
			// code to convert from  Color to VertexElementColor
			// and return a Color object.
			Color c = new Color ();
			c.R = typ.R;
			c.G = typ.G;
			c.B = typ.B;
			c.R = typ.A;
			return c;
		}

		public static implicit operator VertexElementColor (Color typ)
		{
			// code to convert from  VertextElementColor to Color
			// and return a VertexElementColor object.
			VertexElementColor c = new VertexElementColor (typ);
			return c;
		}

		public static bool operator == (VertexElementColor left, Color right)
		{
			return ( left.R == right.R && left.G == right.G && left.B == right.B && left.A == right.A);
		}

		public static bool operator != (VertexElementColor left, Color right)
		{
			return !(left == right);
		}

		public override bool Equals (object obj)
		{
			if (obj == null) {
				return false;
			}
			if (obj.GetType () != base.GetType ()) {
				return false;
			}
			return (this == ((VertexElementColor)obj));
		}

        public UInt32 PackedValue
        {
            get
            {

                // ARGB
                uint _packedValue = 0;
                _packedValue = (_packedValue & 0xffffff00) | R;
                _packedValue = (_packedValue & 0xffff00ff) | ((uint)(G << 8));
                _packedValue = (_packedValue & 0xff00ffff) | ((uint)(B << 16));
                _packedValue = (_packedValue & 0x00ffffff) | ((uint)(A << 24));
                return _packedValue;
            }
            set
            {
                R = (byte)value;
                G = (byte)(value >> 8);
                B = (byte)(value >> 16);
                A = (byte)(value >> 24);
            }
        }
	}

}