Color.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /************************************************************************
  2. * Color.js
  3. ************************************************************************
  4. * Copyright (c) 2021 Pedro Tonini Rosenberg Schneider.
  5. *
  6. * This file is part of Pandora.
  7. *
  8. * Pandora is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * Pandora is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with Pandora. If not, see <https://www.gnu.org/licenses/>.
  20. *************************************************************************/
  21. class Color
  22. {
  23. constructor(r, g, b, a = 255)
  24. {
  25. this.r = r;
  26. this.g = g;
  27. this.b = b;
  28. this.a = a;
  29. this.p5Color = color(this.r, this.g, this.b, this.a);
  30. }
  31. getP5Color()
  32. {
  33. this.p5Color.setRed(this.r);
  34. this.p5Color.setGreen(this.g);
  35. this.p5Color.setBlue(this.b);
  36. this.p5Color.setAlpha(this.a);
  37. return this.p5Color;
  38. }
  39. }