index.js 868 B

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports["default"] = void 0;
  6. var _utils = require("@jimp/utils");
  7. /**
  8. * Inverts the image
  9. * @param {function(Error, Jimp)} cb (optional) a callback for when complete
  10. * @returns {Jimp} this for chaining of methods
  11. */
  12. var _default = function _default() {
  13. return {
  14. invert: function invert(cb) {
  15. this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {
  16. this.bitmap.data[idx] = 255 - this.bitmap.data[idx];
  17. this.bitmap.data[idx + 1] = 255 - this.bitmap.data[idx + 1];
  18. this.bitmap.data[idx + 2] = 255 - this.bitmap.data[idx + 2];
  19. });
  20. if ((0, _utils.isNodePattern)(cb)) {
  21. cb.call(this, null, this);
  22. }
  23. return this;
  24. }
  25. };
  26. };
  27. exports["default"] = _default;
  28. //# sourceMappingURL=index.js.map