ColorStyle.js 753 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import {Style} from "./Style";
  2. /**
  3. * Simple solid color style represented and stored as a CSS color.
  4. *
  5. * @class
  6. * @extends {Style}
  7. * @param {string} color Color of the style, if undefined it is set to black.
  8. */
  9. function ColorStyle(color)
  10. {
  11. /**
  12. * Color of this style object.
  13. *
  14. * @type {string}
  15. */
  16. this.color = color || "#000000";
  17. }
  18. ColorStyle.prototype = Object.create(Style.prototype);
  19. Style.register(ColorStyle, "Color");
  20. ColorStyle.prototype.get = function(context)
  21. {
  22. return this.color;
  23. };
  24. ColorStyle.prototype.serialize = function()
  25. {
  26. return {
  27. type: "Color",
  28. color: this.color
  29. };
  30. };
  31. ColorStyle.prototype.parse = function(data)
  32. {
  33. this.color = data.color;
  34. };
  35. export {ColorStyle};