Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MR414N-ID
GitHub Repository: MR414N-ID/botku2
Path: blob/master/node_modules/@jimp/plugin-flip/dist/index.js
1129 views
1
"use strict";
2
3
Object.defineProperty(exports, "__esModule", {
4
value: true
5
});
6
exports["default"] = void 0;
7
8
var _utils = require("@jimp/utils");
9
10
/**
11
* Flip the image horizontally
12
* @param {boolean} horizontal a Boolean, if true the image will be flipped horizontally
13
* @param {boolean} vertical a Boolean, if true the image will be flipped vertically
14
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
15
* @returns {Jimp} this for chaining of methods
16
*/
17
function flipFn(horizontal, vertical, cb) {
18
if (typeof horizontal !== 'boolean' || typeof vertical !== 'boolean') return _utils.throwError.call(this, 'horizontal and vertical must be Booleans', cb);
19
var bitmap = Buffer.alloc(this.bitmap.data.length);
20
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {
21
var _x = horizontal ? this.bitmap.width - 1 - x : x;
22
23
var _y = vertical ? this.bitmap.height - 1 - y : y;
24
25
var _idx = this.bitmap.width * _y + _x << 2;
26
27
var data = this.bitmap.data.readUInt32BE(idx);
28
bitmap.writeUInt32BE(data, _idx);
29
});
30
this.bitmap.data = Buffer.from(bitmap);
31
32
if ((0, _utils.isNodePattern)(cb)) {
33
cb.call(this, null, this);
34
}
35
36
return this;
37
}
38
39
var _default = function _default() {
40
return {
41
flip: flipFn,
42
mirror: flipFn
43
};
44
};
45
46
exports["default"] = _default;
47
module.exports = exports.default;
48
//# sourceMappingURL=index.js.map
49