Path: blob/master/node_modules/@jimp/plugin-flip/dist/index.js
1129 views
"use strict";12Object.defineProperty(exports, "__esModule", {3value: true4});5exports["default"] = void 0;67var _utils = require("@jimp/utils");89/**10* Flip the image horizontally11* @param {boolean} horizontal a Boolean, if true the image will be flipped horizontally12* @param {boolean} vertical a Boolean, if true the image will be flipped vertically13* @param {function(Error, Jimp)} cb (optional) a callback for when complete14* @returns {Jimp} this for chaining of methods15*/16function flipFn(horizontal, vertical, cb) {17if (typeof horizontal !== 'boolean' || typeof vertical !== 'boolean') return _utils.throwError.call(this, 'horizontal and vertical must be Booleans', cb);18var bitmap = Buffer.alloc(this.bitmap.data.length);19this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {20var _x = horizontal ? this.bitmap.width - 1 - x : x;2122var _y = vertical ? this.bitmap.height - 1 - y : y;2324var _idx = this.bitmap.width * _y + _x << 2;2526var data = this.bitmap.data.readUInt32BE(idx);27bitmap.writeUInt32BE(data, _idx);28});29this.bitmap.data = Buffer.from(bitmap);3031if ((0, _utils.isNodePattern)(cb)) {32cb.call(this, null, this);33}3435return this;36}3738var _default = function _default() {39return {40flip: flipFn,41mirror: flipFn42};43};4445exports["default"] = _default;46module.exports = exports.default;47//# sourceMappingURL=index.js.map4849