Mask.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import {Object2D} from "../../Object2D.js";
  2. /**
  3. * A mask can be used to set the drawing region.
  4. *
  5. * Masks are treated as objects their shape is used to filter other objects shape.
  6. *
  7. * Multiple mask objects can be active simultaneously, they have to be attached to the object mask list to filter the render region.
  8. *
  9. * A mask objects is draw using the context.clip() method.
  10. *
  11. * @class
  12. * @extends {Object2D}
  13. */
  14. function Mask()
  15. {
  16. Object2D.call(this);
  17. }
  18. Mask.prototype = Object.create(Object2D.prototype);
  19. Mask.prototype.constructor = Mask;
  20. Mask.prototype.type = "Mask";
  21. Object2D.register(Mask, "Mask");
  22. Mask.prototype.isMask = true;
  23. /**
  24. * Clip the canvas context. Define a clipping path and set the clip using the context.clip() method.
  25. *
  26. * Ensures that next objects being drawn are clipped to the path stored here.
  27. *
  28. * More information about canvas clipping https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/clip.
  29. *
  30. * @param {CanvasRenderingContext2D} context Canvas 2d drawing context.
  31. * @param {Viewport} viewport Viewport applied to the canvas.
  32. * @param {DOM} canvas DOM canvas element where the content is being drawn.
  33. */
  34. Mask.prototype.clip = function(context, viewport, canvas){};
  35. export {Mask};