Pattern.js 462 B

123456789101112131415
  1. var Pattern = function (image, repeat) {
  2. // Should do nothing more in this constructor. Because gradient can be
  3. // declard by `color: {image: ...}`, where this constructor will not be called.
  4. this.image = image;
  5. this.repeat = repeat; // Can be cloned
  6. this.type = 'pattern';
  7. };
  8. Pattern.prototype.getCanvasPattern = function (ctx) {
  9. return ctx.createPattern(this.image, this.repeat || 'repeat');
  10. };
  11. var _default = Pattern;
  12. module.exports = _default;