Path: blob/master/node_modules/@jimp/utils/dist/index.js
1126 views
"use strict";12var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");34Object.defineProperty(exports, "__esModule", {5value: true6});7exports.isNodePattern = isNodePattern;8exports.throwError = throwError;9exports.scan = scan;10exports.scanIterator = scanIterator;1112var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));1314var _marked =15/*#__PURE__*/16_regenerator["default"].mark(scanIterator);1718function isNodePattern(cb) {19if (typeof cb === 'undefined') {20return false;21}2223if (typeof cb !== 'function') {24throw new TypeError('Callback must be a function');25}2627return true;28}2930function throwError(error, cb) {31if (typeof error === 'string') {32error = new Error(error);33}3435if (typeof cb === 'function') {36return cb.call(this, error);37}3839throw error;40}4142function scan(image, x, y, w, h, f) {43// round input44x = Math.round(x);45y = Math.round(y);46w = Math.round(w);47h = Math.round(h);4849for (var _y = y; _y < y + h; _y++) {50for (var _x = x; _x < x + w; _x++) {51var idx = image.bitmap.width * _y + _x << 2;52f.call(image, _x, _y, idx);53}54}5556return image;57}5859function scanIterator(image, x, y, w, h) {60var _y, _x, idx;6162return _regenerator["default"].wrap(function scanIterator$(_context) {63while (1) {64switch (_context.prev = _context.next) {65case 0:66// round input67x = Math.round(x);68y = Math.round(y);69w = Math.round(w);70h = Math.round(h);71_y = y;7273case 5:74if (!(_y < y + h)) {75_context.next = 17;76break;77}7879_x = x;8081case 7:82if (!(_x < x + w)) {83_context.next = 14;84break;85}8687idx = image.bitmap.width * _y + _x << 2;88_context.next = 11;89return {90x: _x,91y: _y,92idx: idx,93image: image94};9596case 11:97_x++;98_context.next = 7;99break;100101case 14:102_y++;103_context.next = 5;104break;105106case 17:107case "end":108return _context.stop();109}110}111}, _marked);112}113//# sourceMappingURL=index.js.map114115