f01dd1c7f9a1d22680610b06a052d301999351f6257203a2c70a5ef4153f25fbc5ec85c6d460136f2a993825469ab816d7fc0cb5e643f684a73b802946a625 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. /**
  6. * A very VM friendly rgba datastructure.
  7. * Please don't touch unless you take a look at the IR.
  8. */
  9. export class RGBA8 {
  10. constructor(r, g, b, a) {
  11. this._rgba8Brand = undefined;
  12. this.r = RGBA8._clamp(r);
  13. this.g = RGBA8._clamp(g);
  14. this.b = RGBA8._clamp(b);
  15. this.a = RGBA8._clamp(a);
  16. }
  17. equals(other) {
  18. return (this.r === other.r
  19. && this.g === other.g
  20. && this.b === other.b
  21. && this.a === other.a);
  22. }
  23. static _clamp(c) {
  24. if (c < 0) {
  25. return 0;
  26. }
  27. if (c > 255) {
  28. return 255;
  29. }
  30. return c | 0;
  31. }
  32. }
  33. RGBA8.Empty = new RGBA8(0, 0, 0, 0);