@jimp/plugin-fisheye
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,51 +15,42 @@ * Creates a circle out of an image. | ||
*/ | ||
var _default = function _default() { | ||
return { | ||
fisheye: function fisheye() { | ||
var _this = this; | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { | ||
var _default = () => ({ | ||
fisheye() { | ||
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { | ||
r: 2.5 | ||
}; | ||
let cb = arguments.length > 1 ? arguments[1] : undefined; | ||
if (typeof options === "function") { | ||
cb = options; | ||
options = { | ||
r: 2.5 | ||
}; | ||
var cb = arguments.length > 1 ? arguments[1] : undefined; | ||
} | ||
const source = this.cloneQuiet(); | ||
const { | ||
width, | ||
height | ||
} = source.bitmap; | ||
source.scanQuiet(0, 0, width, height, (x, y) => { | ||
const hx = x / width; | ||
const hy = y / height; | ||
const r = Math.sqrt(Math.pow(hx - 0.5, 2) + Math.pow(hy - 0.5, 2)); | ||
const rn = 2 * Math.pow(r, options.r); | ||
const cosA = (hx - 0.5) / r; | ||
const sinA = (hy - 0.5) / r; | ||
const newX = Math.round((rn * cosA + 0.5) * width); | ||
const newY = Math.round((rn * sinA + 0.5) * height); | ||
const color = source.getPixelColor(newX, newY); | ||
this.setPixelColor(color, x, y); | ||
}); | ||
if (typeof options === "function") { | ||
cb = options; | ||
options = { | ||
r: 2.5 | ||
}; | ||
} | ||
var source = this.cloneQuiet(); | ||
var _source$bitmap = source.bitmap, | ||
width = _source$bitmap.width, | ||
height = _source$bitmap.height; | ||
source.scanQuiet(0, 0, width, height, function (x, y) { | ||
var hx = x / width; | ||
var hy = y / height; | ||
var r = Math.sqrt(Math.pow(hx - 0.5, 2) + Math.pow(hy - 0.5, 2)); | ||
var rn = 2 * Math.pow(r, options.r); | ||
var cosA = (hx - 0.5) / r; | ||
var sinA = (hy - 0.5) / r; | ||
var newX = Math.round((rn * cosA + 0.5) * width); | ||
var newY = Math.round((rn * sinA + 0.5) * height); | ||
var color = source.getPixelColor(newX, newY); | ||
_this.setPixelColor(color, x, y); | ||
}); | ||
/* Set center pixel color, otherwise it will be transparent */ | ||
this.setPixelColor(source.getPixelColor(width / 2, height / 2), width / 2, height / 2); | ||
if ((0, _utils.isNodePattern)(cb)) { | ||
cb.call(this, null, this); | ||
} | ||
return this; | ||
/* Set center pixel color, otherwise it will be transparent */ | ||
this.setPixelColor(source.getPixelColor(width / 2, height / 2), width / 2, height / 2); | ||
if ((0, _utils.isNodePattern)(cb)) { | ||
cb.call(this, null, this); | ||
} | ||
}; | ||
}; | ||
exports["default"] = _default; | ||
return this; | ||
} | ||
}); | ||
exports.default = _default; | ||
module.exports = exports.default; | ||
//# sourceMappingURL=index.js.map |
@@ -1,10 +0,3 @@ | ||
"use strict"; | ||
import { isNodePattern } from "@jimp/utils"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = void 0; | ||
var _utils = require("@jimp/utils"); | ||
/** | ||
@@ -16,50 +9,40 @@ * Creates a circle out of an image. | ||
*/ | ||
var _default = function _default() { | ||
return { | ||
fisheye: function fisheye() { | ||
var _this = this; | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { | ||
export default (() => ({ | ||
fisheye() { | ||
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { | ||
r: 2.5 | ||
}; | ||
let cb = arguments.length > 1 ? arguments[1] : undefined; | ||
if (typeof options === "function") { | ||
cb = options; | ||
options = { | ||
r: 2.5 | ||
}; | ||
var cb = arguments.length > 1 ? arguments[1] : undefined; | ||
} | ||
const source = this.cloneQuiet(); | ||
const { | ||
width, | ||
height | ||
} = source.bitmap; | ||
source.scanQuiet(0, 0, width, height, (x, y) => { | ||
const hx = x / width; | ||
const hy = y / height; | ||
const r = Math.sqrt(Math.pow(hx - 0.5, 2) + Math.pow(hy - 0.5, 2)); | ||
const rn = 2 * Math.pow(r, options.r); | ||
const cosA = (hx - 0.5) / r; | ||
const sinA = (hy - 0.5) / r; | ||
const newX = Math.round((rn * cosA + 0.5) * width); | ||
const newY = Math.round((rn * sinA + 0.5) * height); | ||
const color = source.getPixelColor(newX, newY); | ||
this.setPixelColor(color, x, y); | ||
}); | ||
if (typeof options === "function") { | ||
cb = options; | ||
options = { | ||
r: 2.5 | ||
}; | ||
} | ||
var source = this.cloneQuiet(); | ||
var _source$bitmap = source.bitmap, | ||
width = _source$bitmap.width, | ||
height = _source$bitmap.height; | ||
source.scanQuiet(0, 0, width, height, function (x, y) { | ||
var hx = x / width; | ||
var hy = y / height; | ||
var r = Math.sqrt(Math.pow(hx - 0.5, 2) + Math.pow(hy - 0.5, 2)); | ||
var rn = 2 * Math.pow(r, options.r); | ||
var cosA = (hx - 0.5) / r; | ||
var sinA = (hy - 0.5) / r; | ||
var newX = Math.round((rn * cosA + 0.5) * width); | ||
var newY = Math.round((rn * sinA + 0.5) * height); | ||
var color = source.getPixelColor(newX, newY); | ||
_this.setPixelColor(color, x, y); | ||
}); | ||
/* Set center pixel color, otherwise it will be transparent */ | ||
this.setPixelColor(source.getPixelColor(width / 2, height / 2), width / 2, height / 2); | ||
if ((0, _utils.isNodePattern)(cb)) { | ||
cb.call(this, null, this); | ||
} | ||
return this; | ||
/* Set center pixel color, otherwise it will be transparent */ | ||
this.setPixelColor(source.getPixelColor(width / 2, height / 2), width / 2, height / 2); | ||
if (isNodePattern(cb)) { | ||
cb.call(this, null, this); | ||
} | ||
}; | ||
}; | ||
exports["default"] = _default; | ||
return this; | ||
} | ||
})); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@jimp/plugin-fisheye", | ||
"version": "0.20.2", | ||
"version": "0.21.0--canary.1149.3239903.0", | ||
"description": "Apply a fisheye effect to an image.", | ||
@@ -24,4 +24,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" | ||
}, | ||
@@ -32,4 +31,4 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@jimp/custom": "^0.20.2", | ||
"@jimp/test-utils": "^0.20.2" | ||
"@jimp/custom": "0.21.0--canary.1149.3239903.0", | ||
"@jimp/test-utils": "0.21.0--canary.1149.3239903.0" | ||
}, | ||
@@ -39,3 +38,3 @@ "publishConfig": { | ||
}, | ||
"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
18688
246
+ 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)