@jimp/plugin-displace
Advanced tools
Comparing version 0.20.2 to 0.21.0--canary.1149.3239903.0
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = void 0; | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
exports.default = void 0; | ||
var _utils = require("@jimp/utils"); | ||
/** | ||
@@ -21,34 +15,27 @@ * Displaces the image based on the provided displacement map | ||
*/ | ||
var _default = function _default() { | ||
return { | ||
displace: function displace(map, offset, cb) { | ||
if ((0, _typeof2["default"])(map) !== "object" || map.constructor !== this.constructor) { | ||
return _utils.throwError.call(this, "The source must be a Jimp image", cb); | ||
} | ||
if (typeof offset !== "number") { | ||
return _utils.throwError.call(this, "factor must be a number", cb); | ||
} | ||
var source = this.cloneQuiet(); | ||
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) { | ||
var displacement = map.bitmap.data[idx] / 256 * offset; | ||
displacement = Math.round(displacement); | ||
var 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 ((0, _utils.isNodePattern)(cb)) { | ||
cb.call(this, null, this); | ||
} | ||
return this; | ||
var _default = () => ({ | ||
displace(map, offset, cb) { | ||
if (typeof map !== "object" || map.constructor !== this.constructor) { | ||
return _utils.throwError.call(this, "The source must be a Jimp image", cb); | ||
} | ||
}; | ||
}; | ||
exports["default"] = _default; | ||
if (typeof offset !== "number") { | ||
return _utils.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 ((0, _utils.isNodePattern)(cb)) { | ||
cb.call(this, null, this); | ||
} | ||
return this; | ||
} | ||
}); | ||
exports.default = _default; | ||
module.exports = exports.default; | ||
//# sourceMappingURL=index.js.map |
@@ -1,14 +0,3 @@ | ||
"use strict"; | ||
import { isNodePattern, throwError } from "@jimp/utils"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = void 0; | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
var _utils = require("@jimp/utils"); | ||
/** | ||
@@ -21,33 +10,25 @@ * Displaces the image based on the provided displacement map | ||
*/ | ||
var _default = function _default() { | ||
return { | ||
displace: function displace(map, offset, cb) { | ||
if ((0, _typeof2["default"])(map) !== "object" || map.constructor !== this.constructor) { | ||
return _utils.throwError.call(this, "The source must be a Jimp image", cb); | ||
} | ||
if (typeof offset !== "number") { | ||
return _utils.throwError.call(this, "factor must be a number", cb); | ||
} | ||
var source = this.cloneQuiet(); | ||
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) { | ||
var displacement = map.bitmap.data[idx] / 256 * offset; | ||
displacement = Math.round(displacement); | ||
var 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 ((0, _utils.isNodePattern)(cb)) { | ||
cb.call(this, null, this); | ||
} | ||
return this; | ||
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); | ||
} | ||
}; | ||
}; | ||
exports["default"] = _default; | ||
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; | ||
} | ||
})); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@jimp/plugin-displace", | ||
"version": "0.20.2", | ||
"version": "0.21.0--canary.1149.3239903.0", | ||
"description": "displace an image.", | ||
@@ -21,4 +21,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@babel/runtime": "^7.7.2", | ||
"@jimp/utils": "^0.20.2" | ||
"@jimp/utils": "0.21.0--canary.1149.3239903.0" | ||
}, | ||
@@ -31,3 +30,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "cebbdb72f889102a8e3c42b25ad3243b16e3a485" | ||
"gitHead": "323990352ce279d67297aed097b37bd8ec66ef51" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2
14545
111
+ Added@jimp/utils@0.21.0--canary.1149.3239903.0(transitive)
- Removed@babel/runtime@^7.7.2
- Removed@babel/runtime@7.25.9(transitive)
- Removed@jimp/utils@0.20.2(transitive)
- Removedregenerator-runtime@0.14.1(transitive)