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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266
|
#region License
/*
MIT License
Copyright © 2006 The Mono.Xna Team
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#endregion License
using System;
namespace Microsoft.Xna.Framework
{
public struct Color : IEquatable<Color>
{
// ARGB
private uint _packedValue;
private Color(uint packedValue)
{
_packedValue = packedValue;
// ARGB
//_packedValue = (packedValue << 8) | ((packedValue & 0xff000000) >> 24);
// ABGR
//_packedValue = (packedValue & 0xff00ff00) | ((packedValue & 0x000000ff) << 16) | ((packedValue & 0x00ff0000) >> 16);
}
public Color(Vector4 color)
{
_packedValue = 0;
R = (byte)MathHelper.Clamp(color.X * 255, Byte.MinValue, Byte.MaxValue);
G = (byte)MathHelper.Clamp(color.Y * 255, Byte.MinValue, Byte.MaxValue);
B = (byte)MathHelper.Clamp(color.Z * 255, Byte.MinValue, Byte.MaxValue);
A = (byte)MathHelper.Clamp(color.W * 255, Byte.MinValue, Byte.MaxValue);
}
public Color(Vector3 color)
{
_packedValue = 0;
R = (byte)MathHelper.Clamp(color.X * 255, Byte.MinValue, Byte.MaxValue);
G = (byte)MathHelper.Clamp(color.Y * 255, Byte.MinValue, Byte.MaxValue);
B = (byte)MathHelper.Clamp(color.Z * 255, Byte.MinValue, Byte.MaxValue);
A = 255;
}
public Color(Color color, int alpha)
{
_packedValue = 0;
R = color.R;
G = color.G;
B = color.B;
A = (byte)MathHelper.Clamp(alpha, Byte.MinValue, Byte.MaxValue);
}
public Color(Color color, float alpha)
{
_packedValue = 0;
R = color.R;
G = color.G;
B = color.B;
A = (byte)MathHelper.Clamp(alpha * 255, Byte.MinValue, Byte.MaxValue);
}
public Color(float r, float g, float b)
{
_packedValue = 0;
R = (byte)MathHelper.Clamp(r * 255, Byte.MinValue, Byte.MaxValue);
G = (byte)MathHelper.Clamp(g * 255, Byte.MinValue, Byte.MaxValue);
B = (byte)MathHelper.Clamp(b * 255, Byte.MinValue, Byte.MaxValue);
A = 255;
}
public Color(int r, int g, int b)
{
_packedValue = 0;
R = (byte)MathHelper.Clamp(r, Byte.MinValue, Byte.MaxValue);
G = (byte)MathHelper.Clamp(g, Byte.MinValue, Byte.MaxValue);
B = (byte)MathHelper.Clamp(b, Byte.MinValue, Byte.MaxValue);
A = (byte)255;
}
public Color(int r, int g, int b, int alpha)
{
_packedValue = 0;
R = (byte)MathHelper.Clamp(r, Byte.MinValue, Byte.MaxValue);
G = (byte)MathHelper.Clamp(g, Byte.MinValue, Byte.MaxValue);
B = (byte)MathHelper.Clamp(b, Byte.MinValue, Byte.MaxValue);
A = (byte)MathHelper.Clamp(alpha, Byte.MinValue, Byte.MaxValue);
}
public Color(float r, float g, float b, float alpha)
{
_packedValue = 0;
R = (byte)MathHelper.Clamp(r * 255, Byte.MinValue, Byte.MaxValue);
G = (byte)MathHelper.Clamp(g * 255, Byte.MinValue, Byte.MaxValue);
B = (byte)MathHelper.Clamp(b * 255, Byte.MinValue, Byte.MaxValue);
A = (byte)MathHelper.Clamp(alpha * 255, Byte.MinValue, Byte.MaxValue);
}
public byte B
{
get
{
return (byte)this._packedValue;
}
set
{
this._packedValue = (this._packedValue & 0xffffff00) | value;
}
}
public byte G
{
get
{
return (byte)(this._packedValue >> 8);
}
set
{
this._packedValue = (this._packedValue & 0xffff00ff) | ((uint)(value << 8));
}
}
public byte R
{
get
{
return (byte)(this._packedValue >> 16);
}
set
{
this._packedValue = (this._packedValue & 0xff00ffff) | ((uint)(value << 16 ));
}
}
public byte A
{
get
{
return (byte)(this._packedValue >> 24);
}
set
{
this._packedValue = (this._packedValue & 0x00ffffff) | ((uint)(value << 24));
}
}
public uint GLPackedValue
{
get { return (_packedValue & 0xff00ff00) | ((_packedValue & 0x000000ff) << 16) | ((_packedValue & 0x00ff0000) >> 16); }
}
public static bool operator ==(Color a, Color b)
{
return (a.A == b.A &&
a.R == b.R &&
a.G == b.G &&
a.B == b.B);
}
public static bool operator !=(Color a, Color b)
{
return !(a == b);
}
public override int GetHashCode()
{
return this._packedValue.GetHashCode();
}
public override bool Equals(object obj)
{
return ((obj is Color) && this.Equals((Color)obj));
}
public static Color TransparentBlack
{
get
{
return new Color(0);
}
}
public static Color Transparent
{
get{
return new Color(0);
}
}
public static Color TransparentWhite
{
get
{
return new Color(0xffffff);
}
}
public static Color AliceBlue
{
get
{
return new Color(0xfff0f8ff);
}
}
public static Color AntiqueWhite
{
get
{
return new Color(0xfffaebd7);
}
}
public static Color Aqua
{
get
{
return new Color(0xff00ffff);
}
}
public static Color Aquamarine
{
get
{
return new Color(0xff7fffd4);
}
}
public static Color Azure
{
get
{
return new Color(0xfff0ffff);
}
}
public static Color Beige
{
get
{
return new Color(0xfff5f5dc);
}
}
public static Color Bisque
{
get
{
return new Color(0xffffe4c4);
}
}
public static Color Black
{
get
{
return new Color(0xff000000);
}
}
public static Color BlanchedAlmond
{
get
{
return new Color(0xffffebcd);
}
}
public static Color Blue
{
get
{
return new Color(0xff0000ff);
}
}
public static Color BlueViolet
{
get
{
return new Color(0xff8a2be2);
}
}
public static Color Brown
{
get
{
return new Color(0xffa52a2a);
}
}
public static Color BurlyWood
{
get
{
return new Color(0xffdeb887);
}
}
public static Color CadetBlue
{
get
{
return new Color(0xff5f9ea0);
}
}
public static Color Chartreuse
{
get
{
return new Color(0xff7fff00);
}
}
public static Color Chocolate
{
get
{
return new Color(0xffd2691e);
}
}
public static Color Coral
{
get
{
return new Color(0xffff7f50);
}
}
public static Color CornflowerBlue
{
get
{
return new Color(0xff6495ed);
}
}
public static Color Cornsilk
{
get
{
return new Color(0xfffff8dc);
}
}
public static Color Crimson
{
get
{
return new Color(0xffdc143c);
}
}
public static Color Cyan
{
get
{
return new Color(0xff00ffff);
}
}
public static Color DarkBlue
{
get
{
return new Color(0xff00008b);
}
}
public static Color DarkCyan
{
get
{
return new Color(0xff008b8b);
}
}
public static Color DarkGoldenrod
{
get
{
return new Color(0xffb8860b);
}
}
public static Color DarkGray
{
get
{
return new Color(0xffa9a9a9);
}
}
public static Color DarkGreen
{
get
{
return new Color(0xff006400);
}
}
public static Color DarkKhaki
{
get
{
return new Color(0xffbdb76b);
}
}
public static Color DarkMagenta
{
get
{
return new Color(0xff8b008b);
}
}
public static Color DarkOliveGreen
{
get
{
return new Color(0xff556b2f);
}
}
public static Color DarkOrange
{
get
{
return new Color(0xffff8c00);
}
}
public static Color DarkOrchid
{
get
{
return new Color(0xff9932cc);
}
}
public static Color DarkRed
{
get
{
return new Color(0xff8b0000);
}
}
public static Color DarkSalmon
{
get
{
return new Color(0xffe9967a);
}
}
public static Color DarkSeaGreen
{
get
{
return new Color(0xff8fbc8b);
}
}
public static Color DarkSlateBlue
{
get
{
return new Color(0xff483d8b);
}
}
public static Color DarkSlateGray
{
get
{
return new Color(0xff2f4f4f);
}
}
public static Color DarkTurquoise
{
get
{
return new Color(0xff00ced1);
}
}
public static Color DarkViolet
{
get
{
return new Color(0xff9400d3);
}
}
public static Color DeepPink
{
get
{
return new Color(0xffff1493);
}
}
public static Color DeepSkyBlue
{
get
{
return new Color(0xff00bfff);
}
}
public static Color DimGray
{
get
{
return new Color(0xff696969);
}
}
public static Color DodgerBlue
{
get
{
return new Color(0xff1e90ff);
}
}
public static Color Firebrick
{
get
{
return new Color(0xffb22222);
}
}
public static Color FloralWhite
{
get
{
return new Color(0xfffffaf0);
}
}
public static Color ForestGreen
{
get
{
return new Color(0xff228b22);
}
}
public static Color Fuchsia
{
get
{
return new Color(0xffff00ff);
}
}
public static Color Gainsboro
{
get
{
return new Color(0xffdcdcdc);
}
}
public static Color GhostWhite
{
get
{
return new Color(0xfff8f8ff);
}
}
public static Color Gold
{
get
{
return new Color(0xffffd700);
}
}
public static Color Goldenrod
{
get
{
return new Color(0xffdaa520);
}
}
public static Color Gray
{
get
{
return new Color(0xff808080);
}
}
public static Color Green
{
get
{
return new Color(0xff008000);
}
}
public static Color GreenYellow
{
get
{
return new Color(0xffadff2f);
}
}
public static Color Honeydew
{
get
{
return new Color(0xfff0fff0);
}
}
public static Color HotPink
{
get
{
return new Color(0xffff69b4);
}
}
public static Color IndianRed
{
get
{
return new Color(0xffcd5c5c);
}
}
public static Color Indigo
{
get
{
return new Color(0xff4b0082);
}
}
public static Color Ivory
{
get
{
return new Color(0xfffffff0);
}
}
public static Color Khaki
{
get
{
return new Color(0xfff0e68c);
}
}
public static Color Lavender
{
get
{
return new Color(0xffe6e6fa);
}
}
public static Color LavenderBlush
{
get
{
return new Color(0xfffff0f5);
}
}
public static Color LawnGreen
{
get
{
return new Color(0xff7cfc00);
}
}
public static Color LemonChiffon
{
get
{
return new Color(0xfffffacd);
}
}
public static Color LightBlue
{
get
{
return new Color(0xffadd8e6);
}
}
public static Color LightCoral
{
get
{
return new Color(0xfff08080);
}
}
public static Color LightCyan
{
get
{
return new Color(0xffe0ffff);
}
}
public static Color LightGoldenrodYellow
{
get
{
return new Color(0xfffafad2);
}
}
public static Color LightGreen
{
get
{
return new Color(0xff90ee90);
}
}
public static Color LightGray
{
get
{
return new Color(0xffd3d3d3);
}
}
public static Color LightPink
{
get
{
return new Color(0xffffb6c1);
}
}
public static Color LightSalmon
{
get
{
return new Color(0xffffa07a);
}
}
public static Color LightSeaGreen
{
get
{
return new Color(0xff20b2aa);
}
}
public static Color LightSkyBlue
{
get
{
return new Color(0xff87cefa);
}
}
public static Color LightSlateGray
{
get
{
return new Color(0xff778899);
}
}
public static Color LightSteelBlue
{
get
{
return new Color(0xffb0c4de);
}
}
public static Color LightYellow
{
get
{
return new Color(0xffffffe0);
}
}
public static Color Lime
{
get
{
return new Color(0xff00ff00);
}
}
public static Color LimeGreen
{
get
{
return new Color(0xff32cd32);
}
}
public static Color Linen
{
get
{
return new Color(0xfffaf0e6);
}
}
public static Color Magenta
{
get
{
return new Color(0xffff00ff);
}
}
public static Color Maroon
{
get
{
return new Color(0xff800000);
}
}
public static Color MediumAquamarine
{
get
{
return new Color(0xff66cdaa);
}
}
public static Color MediumBlue
{
get
{
return new Color(0xff0000cd);
}
}
public static Color MediumOrchid
{
get
{
return new Color(0xffba55d3);
}
}
public static Color MediumPurple
{
get
{
return new Color(0xff9370db);
}
}
public static Color MediumSeaGreen
{
get
{
return new Color(0xff3cb371);
}
}
public static Color MediumSlateBlue
{
get
{
return new Color(0xff7b68ee);
}
}
public static Color MediumSpringGreen
{
get
{
return new Color(0xff00fa9a);
}
}
public static Color MediumTurquoise
{
get
{
return new Color(0xff48d1cc);
}
}
public static Color MediumVioletRed
{
get
{
return new Color(0xffc71585);
}
}
public static Color MidnightBlue
{
get
{
return new Color(0xff191970);
}
}
public static Color MintCream
{
get
{
return new Color(0xfff5fffa);
}
}
public static Color MistyRose
{
get
{
return new Color(0xffffe4e1);
}
}
public static Color Moccasin
{
get
{
return new Color(0xffffe4b5);
}
}
public static Color NavajoWhite
{
get
{
return new Color(0xffffdead);
}
}
public static Color Navy
{
get
{
return new Color(0xff000080);
}
}
public static Color OldLace
{
get
{
return new Color(0xfffdf5e6);
}
}
public static Color Olive
{
get
{
return new Color(0xff808000);
}
}
public static Color OliveDrab
{
get
{
return new Color(0xff6b8e23);
}
}
public static Color Orange
{
get
{
return new Color(0xffffa500);
}
}
public static Color OrangeRed
{
get
{
return new Color(0xffff4500);
}
}
public static Color Orchid
{
get
{
return new Color(0xffda70d6);
}
}
public static Color PaleGoldenrod
{
get
{
return new Color(0xffeee8aa);
}
}
public static Color PaleGreen
{
get
{
return new Color(0xff98fb98);
}
}
public static Color PaleTurquoise
{
get
{
return new Color(0xffafeeee);
}
}
public static Color PaleVioletRed
{
get
{
return new Color(0xffdb7093);
}
}
public static Color PapayaWhip
{
get
{
return new Color(0xffffefd5);
}
}
public static Color PeachPuff
{
get
{
return new Color(0xffffdab9);
}
}
public static Color Peru
{
get
{
return new Color(0xffcd853f);
}
}
public static Color Pink
{
get
{
return new Color(0xffffc0cb);
}
}
public static Color Plum
{
get
{
return new Color(0xffdda0dd);
}
}
public static Color PowderBlue
{
get
{
return new Color(0xffb0e0e6);
}
}
public static Color Purple
{
get
{
return new Color(0xff800080);
}
}
public static Color Red
{
get
{
return new Color(0xffff0000);
}
}
public static Color RosyBrown
{
get
{
return new Color(0xffbc8f8f);
}
}
public static Color RoyalBlue
{
get
{
return new Color(0xff4169e1);
}
}
public static Color SaddleBrown
{
get
{
return new Color(0xff8b4513);
}
}
public static Color Salmon
{
get
{
return new Color(0xfffa8072);
}
}
public static Color SandyBrown
{
get
{
return new Color(0xfff4a460);
}
}
public static Color SeaGreen
{
get
{
return new Color(0xff2e8b57);
}
}
public static Color SeaShell
{
get
{
return new Color(0xfffff5ee);
}
}
public static Color Sienna
{
get
{
return new Color(0xffa0522d);
}
}
public static Color Silver
{
get
{
return new Color(0xffc0c0c0);
}
}
public static Color SkyBlue
{
get
{
return new Color(0xff87ceeb);
}
}
public static Color SlateBlue
{
get
{
return new Color(0xff6a5acd);
}
}
public static Color SlateGray
{
get
{
return new Color(0xff708090);
}
}
public static Color Snow
{
get
{
return new Color(0xfffffafa);
}
}
public static Color SpringGreen
{
get
{
return new Color(0xff00ff7f);
}
}
public static Color SteelBlue
{
get
{
return new Color(0xff4682b4);
}
}
public static Color Tan
{
get
{
return new Color(0xffd2b48c);
}
}
public static Color Teal
{
get
{
return new Color(0xff008080);
}
}
public static Color Thistle
{
get
{
return new Color(0xffd8bfd8);
}
}
public static Color Tomato
{
get
{
return new Color(0xffff6347);
}
}
public static Color Turquoise
{
get
{
return new Color(0xff40e0d0);
}
}
public static Color Violet
{
get
{
return new Color(0xffee82ee);
}
}
public static Color Wheat
{
get
{
return new Color(0xfff5deb3);
}
}
public static Color White
{
get
{
return new Color(uint.MaxValue);
}
}
public static Color WhiteSmoke
{
get
{
return new Color(0xfff5f5f5);
}
}
public static Color Yellow
{
get
{
return new Color(0xffffff00);
}
}
public static Color YellowGreen
{
get
{
return new Color(0xff9acd32);
}
}
public static Color Lerp(Color value1, Color value2, Single amount)
{
byte Red = (byte)MathHelper.Clamp(MathHelper.Lerp(value1.R, value2.R, amount), Byte.MinValue, Byte.MaxValue);
byte Green = (byte)MathHelper.Clamp(MathHelper.Lerp(value1.G, value2.G, amount), Byte.MinValue, Byte.MaxValue);
byte Blue = (byte)MathHelper.Clamp(MathHelper.Lerp(value1.B, value2.B, amount), Byte.MinValue, Byte.MaxValue);
byte Alpha = (byte)MathHelper.Clamp(MathHelper.Lerp(value1.A, value2.A, amount), Byte.MinValue, Byte.MaxValue);
return new Color( Red, Green, Blue, Alpha );
}
public static Color Multiply( Color value, float scale)
{
byte Red = (byte)(value.R * scale);
byte Green = (byte)(value.G * scale);
byte Blue = (byte)(value.B * scale);
byte Alpha = (byte)(value.A * scale);
return new Color( Red, Green, Blue, Alpha );
}
public static Color operator *(Color value, float scale)
{
return Multiply(value, scale);
}
public Vector3 ToVector3()
{
return new Vector3(R / 255.0f, G / 255.0f, B / 255.0f);
}
public Vector4 ToVector4()
{
return new Vector4(R / 255.0f, G / 255.0f, B / 255.0f, A / 255.0f);
}
public UInt32 PackedValue
{
get { return _packedValue; }
set { _packedValue = value; }
}
public override string ToString ()
{
return string.Format("[Color: R={0}, G={1}, B={2}, A={3}, PackedValue={4}]", R, G, B, A, PackedValue);
}
public static Color FromNonPremultiplied(Vector4 vector)
{
return new Color(vector.X * vector.W, vector.Y * vector.W, vector.Z * vector.W, vector.W);
}
public static Color FromNonPremultiplied(int r, int g, int b, int a)
{
return new Color((byte)(r * a / 255),(byte)(g * a / 255), (byte)(b * a / 255), a);
}
#region IEquatable<Color> Members
public bool Equals(Color other)
{
return this.GLPackedValue == other.GLPackedValue;
}
#endregion
}
}
|