Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/invoice_pdf/node_modules/@jimp/plugin-displace/src/ drwxr-xr-x | |
| Viewing file: Select action/file-type: import { isNodePattern, throwError } from "@jimp/utils";
/**
* Displaces the image based on the provided displacement map
* @param {object} map the source Jimp instance
* @param {number} offset the maximum displacement value
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
* @returns {Jimp} this for chaining of methods
*/
export default () => ({
displace(map, offset, cb) {
if (typeof map !== "object" || map.constructor !== this.constructor) {
return throwError.call(this, "The source must be a Jimp image", cb);
}
if (typeof offset !== "number") {
return throwError.call(this, "factor must be a number", cb);
}
const source = this.cloneQuiet();
this.scanQuiet(
0,
0,
this.bitmap.width,
this.bitmap.height,
function (x, y, idx) {
let displacement = (map.bitmap.data[idx] / 256) * offset;
displacement = Math.round(displacement);
const ids = this.getPixelIndex(x + displacement, y);
this.bitmap.data[ids] = source.bitmap.data[idx];
this.bitmap.data[ids + 1] = source.bitmap.data[idx + 1];
this.bitmap.data[ids + 2] = source.bitmap.data[idx + 2];
}
);
if (isNodePattern(cb)) {
cb.call(this, null, this);
}
return this;
},
});
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.01 ]-- |