OSMDColor.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * Represents a color in RGBA
  3. */
  4. export class OSMDColor {
  5. public alpha: number;
  6. public red: number;
  7. public green: number;
  8. public blue: number;
  9. /*constructor(alpha: number, red: number, green: number, blue: number) {
  10. this.alpha = alpha;
  11. this.red = red;
  12. this.green = green;
  13. this.blue = blue;
  14. }*/
  15. /*
  16. * Color names are based on the definitions at https://msdn.microsoft.com/de-de/library/aa358802(vs.85).aspx
  17. * ...but changed a bit by the famous Mc Overacre
  18. */
  19. constructor(red: number, green: number, blue: number) {
  20. this.alpha = 255;
  21. this.red = red;
  22. this.green = green;
  23. this.blue = blue;
  24. }
  25. public static get Black(): OSMDColor {
  26. return new OSMDColor(0, 0, 0);
  27. }
  28. public static get DeepSkyBlue(): OSMDColor {
  29. return new OSMDColor(0, 191, 255);
  30. }
  31. public static get Green(): OSMDColor {
  32. return new OSMDColor(20, 160, 20);
  33. }
  34. public static get Magenta(): OSMDColor {
  35. return new OSMDColor(255, 0, 255);
  36. }
  37. public static get Orange(): OSMDColor {
  38. return new OSMDColor(255, 128, 0);
  39. }
  40. public static get Red(): OSMDColor {
  41. return new OSMDColor(240, 20, 20);
  42. }
  43. public static get Disabled(): OSMDColor {
  44. return new OSMDColor(225, 225, 225);
  45. }
  46. public static get DarkBlue(): OSMDColor {
  47. return new OSMDColor(0, 0, 140);
  48. }
  49. // For debugging:
  50. public static get Debug1(): OSMDColor {
  51. return new OSMDColor(200, 0, 140);
  52. }
  53. public static get Debug2(): OSMDColor {
  54. return new OSMDColor(100, 100, 200);
  55. }
  56. public static get Debug3(): OSMDColor {
  57. return new OSMDColor(0, 50, 140);
  58. }
  59. public toString(): string {
  60. return "rgb(" + this.red + "," + this.green + "," + this.blue + "," + this.alpha + ")";
  61. }
  62. }