Source: core/elements/GraphicsElement.js

  1. var updateData = require('../../extras/updateData');
  2. var getData = require('../../extras/getData');
  3. var CONST = require('../const');
  4. /**
  5. * POM Graphics Element
  6. * @class GraphicsElement
  7. * @extends PIXI.Graphics
  8. * @memberof POM
  9. * @constructor
  10. * @param manager {Manager} the core POM Manager
  11. * @param data {Object} data for the element
  12. */
  13. function GraphicsElement(manager, data) {
  14. PIXI.Graphics.call(this);
  15. /**
  16. * @var dataKeys {Object} datakeys (just the default)
  17. */
  18. this.dataKeys = CONST.DEFAULT_DATAKEYS;
  19. this.manager = manager;
  20. this.type = 'graphics';
  21. this.updateData(data||{});
  22. }
  23. GraphicsElement.prototype = Object.create(PIXI.Graphics.prototype);
  24. module.exports = GraphicsElement;
  25. /**
  26. * update data of graphics from JSON decoded object
  27. *
  28. * @param data {Object} JSON decoded object representing the content
  29. */
  30. GraphicsElement.prototype.updateData = function (data) {
  31. updateData(this, data);
  32. };
  33. /**
  34. * get data of SpriteElement (including defaults)
  35. *
  36. * @returns data {Object} representing the graphics element
  37. */
  38. GraphicsElement.prototype.getData = function () {
  39. return getData(this);
  40. };