Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MR414N-ID
GitHub Repository: MR414N-ID/botku2
Path: blob/master/node_modules/@jimp/utils/dist/index.js
1126 views
1
"use strict";
2
3
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
5
Object.defineProperty(exports, "__esModule", {
6
value: true
7
});
8
exports.isNodePattern = isNodePattern;
9
exports.throwError = throwError;
10
exports.scan = scan;
11
exports.scanIterator = scanIterator;
12
13
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
14
15
var _marked =
16
/*#__PURE__*/
17
_regenerator["default"].mark(scanIterator);
18
19
function isNodePattern(cb) {
20
if (typeof cb === 'undefined') {
21
return false;
22
}
23
24
if (typeof cb !== 'function') {
25
throw new TypeError('Callback must be a function');
26
}
27
28
return true;
29
}
30
31
function throwError(error, cb) {
32
if (typeof error === 'string') {
33
error = new Error(error);
34
}
35
36
if (typeof cb === 'function') {
37
return cb.call(this, error);
38
}
39
40
throw error;
41
}
42
43
function scan(image, x, y, w, h, f) {
44
// round input
45
x = Math.round(x);
46
y = Math.round(y);
47
w = Math.round(w);
48
h = Math.round(h);
49
50
for (var _y = y; _y < y + h; _y++) {
51
for (var _x = x; _x < x + w; _x++) {
52
var idx = image.bitmap.width * _y + _x << 2;
53
f.call(image, _x, _y, idx);
54
}
55
}
56
57
return image;
58
}
59
60
function scanIterator(image, x, y, w, h) {
61
var _y, _x, idx;
62
63
return _regenerator["default"].wrap(function scanIterator$(_context) {
64
while (1) {
65
switch (_context.prev = _context.next) {
66
case 0:
67
// round input
68
x = Math.round(x);
69
y = Math.round(y);
70
w = Math.round(w);
71
h = Math.round(h);
72
_y = y;
73
74
case 5:
75
if (!(_y < y + h)) {
76
_context.next = 17;
77
break;
78
}
79
80
_x = x;
81
82
case 7:
83
if (!(_x < x + w)) {
84
_context.next = 14;
85
break;
86
}
87
88
idx = image.bitmap.width * _y + _x << 2;
89
_context.next = 11;
90
return {
91
x: _x,
92
y: _y,
93
idx: idx,
94
image: image
95
};
96
97
case 11:
98
_x++;
99
_context.next = 7;
100
break;
101
102
case 14:
103
_y++;
104
_context.next = 5;
105
break;
106
107
case 17:
108
case "end":
109
return _context.stop();
110
}
111
}
112
}, _marked);
113
}
114
//# sourceMappingURL=index.js.map
115