@jimp/plugin-gaussian
Advanced tools
Comparing version 0.20.2 to 0.21.0--canary.1149.3239903.0
@@ -6,6 +6,4 @@ "use strict"; | ||
}); | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
var _utils = require("@jimp/utils"); | ||
/** | ||
@@ -17,73 +15,58 @@ * Applies a true Gaussian blur to the image (warning: this is VERY slow) | ||
*/ | ||
var _default = function _default() { | ||
return { | ||
gaussian: function gaussian(r, cb) { | ||
// http://blog.ivank.net/fastest-gaussian-blur.html | ||
if (typeof r !== "number") { | ||
return _utils.throwError.call(this, "r must be a number", cb); | ||
var _default = () => ({ | ||
gaussian(r, cb) { | ||
// http://blog.ivank.net/fastest-gaussian-blur.html | ||
if (typeof r !== "number") { | ||
return _utils.throwError.call(this, "r must be a number", cb); | ||
} | ||
if (r < 1) { | ||
return _utils.throwError.call(this, "r must be greater than 0", cb); | ||
} | ||
const rs = Math.ceil(r * 2.57); // significant radius | ||
const range = rs * 2 + 1; | ||
const rr2 = r * r * 2; | ||
const rr2pi = rr2 * Math.PI; | ||
const weights = []; | ||
for (let y = 0; y < range; y++) { | ||
weights[y] = []; | ||
for (let x = 0; x < range; x++) { | ||
const dsq = (x - rs) ** 2 + (y - rs) ** 2; | ||
weights[y][x] = Math.exp(-dsq / rr2) / rr2pi; | ||
} | ||
if (r < 1) { | ||
return _utils.throwError.call(this, "r must be greater than 0", cb); | ||
} | ||
var rs = Math.ceil(r * 2.57); // significant radius | ||
var range = rs * 2 + 1; | ||
var rr2 = r * r * 2; | ||
var rr2pi = rr2 * Math.PI; | ||
var weights = []; | ||
for (var y = 0; y < range; y++) { | ||
weights[y] = []; | ||
for (var x = 0; x < range; x++) { | ||
var dsq = Math.pow(x - rs, 2) + Math.pow(y - rs, 2); | ||
weights[y][x] = Math.exp(-dsq / rr2) / rr2pi; | ||
} | ||
} | ||
for (var _y = 0; _y < this.bitmap.height; _y++) { | ||
for (var _x = 0; _x < this.bitmap.width; _x++) { | ||
var red = 0; | ||
var green = 0; | ||
var blue = 0; | ||
var alpha = 0; | ||
var wsum = 0; | ||
for (var iy = 0; iy < range; iy++) { | ||
for (var ix = 0; ix < range; ix++) { | ||
var x1 = Math.min(this.bitmap.width - 1, Math.max(0, ix + _x - rs)); | ||
var y1 = Math.min(this.bitmap.height - 1, Math.max(0, iy + _y - rs)); | ||
var weight = weights[iy][ix]; | ||
var _idx = y1 * this.bitmap.width + x1 << 2; | ||
red += this.bitmap.data[_idx] * weight; | ||
green += this.bitmap.data[_idx + 1] * weight; | ||
blue += this.bitmap.data[_idx + 2] * weight; | ||
alpha += this.bitmap.data[_idx + 3] * weight; | ||
wsum += weight; | ||
} | ||
var idx = _y * this.bitmap.width + _x << 2; | ||
this.bitmap.data[idx] = Math.round(red / wsum); | ||
this.bitmap.data[idx + 1] = Math.round(green / wsum); | ||
this.bitmap.data[idx + 2] = Math.round(blue / wsum); | ||
this.bitmap.data[idx + 3] = Math.round(alpha / wsum); | ||
} | ||
for (let y = 0; y < this.bitmap.height; y++) { | ||
for (let x = 0; x < this.bitmap.width; x++) { | ||
let red = 0; | ||
let green = 0; | ||
let blue = 0; | ||
let alpha = 0; | ||
let wsum = 0; | ||
for (let iy = 0; iy < range; iy++) { | ||
for (let ix = 0; ix < range; ix++) { | ||
const x1 = Math.min(this.bitmap.width - 1, Math.max(0, ix + x - rs)); | ||
const y1 = Math.min(this.bitmap.height - 1, Math.max(0, iy + y - rs)); | ||
const weight = weights[iy][ix]; | ||
const idx = y1 * this.bitmap.width + x1 << 2; | ||
red += this.bitmap.data[idx] * weight; | ||
green += this.bitmap.data[idx + 1] * weight; | ||
blue += this.bitmap.data[idx + 2] * weight; | ||
alpha += this.bitmap.data[idx + 3] * weight; | ||
wsum += weight; | ||
} | ||
const idx = y * this.bitmap.width + x << 2; | ||
this.bitmap.data[idx] = Math.round(red / wsum); | ||
this.bitmap.data[idx + 1] = Math.round(green / wsum); | ||
this.bitmap.data[idx + 2] = Math.round(blue / wsum); | ||
this.bitmap.data[idx + 3] = Math.round(alpha / wsum); | ||
} | ||
} | ||
if ((0, _utils.isNodePattern)(cb)) { | ||
cb.call(this, null, this); | ||
} | ||
return this; | ||
} | ||
}; | ||
}; | ||
exports["default"] = _default; | ||
if ((0, _utils.isNodePattern)(cb)) { | ||
cb.call(this, null, this); | ||
} | ||
return this; | ||
} | ||
}); | ||
exports.default = _default; | ||
module.exports = exports.default; | ||
//# sourceMappingURL=index.js.map |
123
es/index.js
@@ -1,10 +0,3 @@ | ||
"use strict"; | ||
import { isNodePattern, throwError } from "@jimp/utils"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = void 0; | ||
var _utils = require("@jimp/utils"); | ||
/** | ||
@@ -16,72 +9,56 @@ * Applies a true Gaussian blur to the image (warning: this is VERY slow) | ||
*/ | ||
var _default = function _default() { | ||
return { | ||
gaussian: function gaussian(r, cb) { | ||
// http://blog.ivank.net/fastest-gaussian-blur.html | ||
if (typeof r !== "number") { | ||
return _utils.throwError.call(this, "r must be a number", cb); | ||
export default (() => ({ | ||
gaussian(r, cb) { | ||
// http://blog.ivank.net/fastest-gaussian-blur.html | ||
if (typeof r !== "number") { | ||
return throwError.call(this, "r must be a number", cb); | ||
} | ||
if (r < 1) { | ||
return throwError.call(this, "r must be greater than 0", cb); | ||
} | ||
const rs = Math.ceil(r * 2.57); // significant radius | ||
const range = rs * 2 + 1; | ||
const rr2 = r * r * 2; | ||
const rr2pi = rr2 * Math.PI; | ||
const weights = []; | ||
for (let y = 0; y < range; y++) { | ||
weights[y] = []; | ||
for (let x = 0; x < range; x++) { | ||
const dsq = (x - rs) ** 2 + (y - rs) ** 2; | ||
weights[y][x] = Math.exp(-dsq / rr2) / rr2pi; | ||
} | ||
if (r < 1) { | ||
return _utils.throwError.call(this, "r must be greater than 0", cb); | ||
} | ||
var rs = Math.ceil(r * 2.57); // significant radius | ||
var range = rs * 2 + 1; | ||
var rr2 = r * r * 2; | ||
var rr2pi = rr2 * Math.PI; | ||
var weights = []; | ||
for (var y = 0; y < range; y++) { | ||
weights[y] = []; | ||
for (var x = 0; x < range; x++) { | ||
var dsq = Math.pow(x - rs, 2) + Math.pow(y - rs, 2); | ||
weights[y][x] = Math.exp(-dsq / rr2) / rr2pi; | ||
} | ||
} | ||
for (var _y = 0; _y < this.bitmap.height; _y++) { | ||
for (var _x = 0; _x < this.bitmap.width; _x++) { | ||
var red = 0; | ||
var green = 0; | ||
var blue = 0; | ||
var alpha = 0; | ||
var wsum = 0; | ||
for (var iy = 0; iy < range; iy++) { | ||
for (var ix = 0; ix < range; ix++) { | ||
var x1 = Math.min(this.bitmap.width - 1, Math.max(0, ix + _x - rs)); | ||
var y1 = Math.min(this.bitmap.height - 1, Math.max(0, iy + _y - rs)); | ||
var weight = weights[iy][ix]; | ||
var _idx = y1 * this.bitmap.width + x1 << 2; | ||
red += this.bitmap.data[_idx] * weight; | ||
green += this.bitmap.data[_idx + 1] * weight; | ||
blue += this.bitmap.data[_idx + 2] * weight; | ||
alpha += this.bitmap.data[_idx + 3] * weight; | ||
wsum += weight; | ||
} | ||
var idx = _y * this.bitmap.width + _x << 2; | ||
this.bitmap.data[idx] = Math.round(red / wsum); | ||
this.bitmap.data[idx + 1] = Math.round(green / wsum); | ||
this.bitmap.data[idx + 2] = Math.round(blue / wsum); | ||
this.bitmap.data[idx + 3] = Math.round(alpha / wsum); | ||
} | ||
for (let y = 0; y < this.bitmap.height; y++) { | ||
for (let x = 0; x < this.bitmap.width; x++) { | ||
let red = 0; | ||
let green = 0; | ||
let blue = 0; | ||
let alpha = 0; | ||
let wsum = 0; | ||
for (let iy = 0; iy < range; iy++) { | ||
for (let ix = 0; ix < range; ix++) { | ||
const x1 = Math.min(this.bitmap.width - 1, Math.max(0, ix + x - rs)); | ||
const y1 = Math.min(this.bitmap.height - 1, Math.max(0, iy + y - rs)); | ||
const weight = weights[iy][ix]; | ||
const idx = y1 * this.bitmap.width + x1 << 2; | ||
red += this.bitmap.data[idx] * weight; | ||
green += this.bitmap.data[idx + 1] * weight; | ||
blue += this.bitmap.data[idx + 2] * weight; | ||
alpha += this.bitmap.data[idx + 3] * weight; | ||
wsum += weight; | ||
} | ||
const idx = y * this.bitmap.width + x << 2; | ||
this.bitmap.data[idx] = Math.round(red / wsum); | ||
this.bitmap.data[idx + 1] = Math.round(green / wsum); | ||
this.bitmap.data[idx + 2] = Math.round(blue / wsum); | ||
this.bitmap.data[idx + 3] = Math.round(alpha / wsum); | ||
} | ||
} | ||
if ((0, _utils.isNodePattern)(cb)) { | ||
cb.call(this, null, this); | ||
} | ||
return this; | ||
} | ||
}; | ||
}; | ||
exports["default"] = _default; | ||
if (isNodePattern(cb)) { | ||
cb.call(this, null, this); | ||
} | ||
return this; | ||
} | ||
})); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@jimp/plugin-gaussian", | ||
"version": "0.20.2", | ||
"version": "0.21.0--canary.1149.3239903.0", | ||
"description": "gaussian blur 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
23034
201
+ Added@jimp/utils@0.21.0--canary.1149.3239903.0(transitive)
- Removed@babel/runtime@^7.7.2
- Removed@babel/runtime@7.26.0(transitive)
- Removed@jimp/utils@0.20.2(transitive)
- Removedregenerator-runtime@0.14.1(transitive)