yeet
This commit is contained in:
23
node_modules/@jimp/plugin-fisheye/CHANGELOG.md
generated
vendored
Normal file
23
node_modules/@jimp/plugin-fisheye/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
# v0.11.0 (Fri May 15 2020)
|
||||
|
||||
#### 🚀 Enhancement
|
||||
|
||||
- Removed Core-JS as a dependency. [#882](https://github.com/oliver-moran/jimp/pull/882) ([@EricRabil](https://github.com/EricRabil))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Eric Rabil ([@EricRabil](https://github.com/EricRabil))
|
||||
|
||||
---
|
||||
|
||||
# v0.9.3 (Tue Nov 26 2019)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- `@jimp/cli`, `@jimp/core`, `@jimp/custom`, `jimp`, `@jimp/plugin-blit`, `@jimp/plugin-blur`, `@jimp/plugin-circle`, `@jimp/plugin-color`, `@jimp/plugin-contain`, `@jimp/plugin-cover`, `@jimp/plugin-crop`, `@jimp/plugin-displace`, `@jimp/plugin-dither`, `@jimp/plugin-fisheye`, `@jimp/plugin-flip`, `@jimp/plugin-gaussian`, `@jimp/plugin-invert`, `@jimp/plugin-mask`, `@jimp/plugin-normalize`, `@jimp/plugin-print`, `@jimp/plugin-resize`, `@jimp/plugin-rotate`, `@jimp/plugin-scale`, `@jimp/plugin-shadow`, `@jimp/plugin-threshold`, `@jimp/plugins`, `@jimp/test-utils`, `@jimp/bmp`, `@jimp/gif`, `@jimp/jpeg`, `@jimp/png`, `@jimp/tiff`, `@jimp/types`, `@jimp/utils`
|
||||
- Fix regeneratorRuntime errors [#815](https://github.com/oliver-moran/jimp/pull/815) ([@crutchcorn](https://github.com/crutchcorn) [@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 2
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
- Corbin Crutchley ([@crutchcorn](https://github.com/crutchcorn))
|
21
node_modules/@jimp/plugin-fisheye/LICENSE
generated
vendored
Normal file
21
node_modules/@jimp/plugin-fisheye/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Oliver Moran
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
27
node_modules/@jimp/plugin-fisheye/README.md
generated
vendored
Normal file
27
node_modules/@jimp/plugin-fisheye/README.md
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
<div align="center">
|
||||
<img width="200" height="200"
|
||||
src="https://s3.amazonaws.com/pix.iemoji.com/images/emoji/apple/ios-11/256/crayon.png">
|
||||
<h1>@jimp/plugin-fishey</h1>
|
||||
<p>Apply a fisheye effect to an image</p>
|
||||
</div>
|
||||
|
||||
## Usage
|
||||
|
||||
- @param {function(Error, Jimp)} options (optional) radius
|
||||
- @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
|
||||
```js
|
||||
import jimp from 'jimp';
|
||||
|
||||
async function main() {
|
||||
const image = await jimp.read('test/image.png');
|
||||
|
||||
image.fisheye();
|
||||
// or
|
||||
image.fisheye({ r: 1.6 });
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
Produces nice images with [@jimp/plugin-circle](../plugin-circle).
|
38
node_modules/@jimp/plugin-fisheye/babel.config.js
generated
vendored
Normal file
38
node_modules/@jimp/plugin-fisheye/babel.config.js
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
module.exports = api => {
|
||||
api.cache(true);
|
||||
|
||||
return {
|
||||
presets: [
|
||||
[
|
||||
'@babel/env',
|
||||
{
|
||||
useBuiltIns: 'usage'
|
||||
}
|
||||
]
|
||||
],
|
||||
|
||||
plugins: [
|
||||
'@babel/proposal-class-properties',
|
||||
'@babel/syntax-object-rest-spread',
|
||||
process.env.BABEL_ENV !== 'module' && 'add-module-exports',
|
||||
[
|
||||
'transform-inline-environment-variables',
|
||||
{ include: ['BABEL_ENV', 'ENV'] }
|
||||
]
|
||||
].filter(Boolean),
|
||||
|
||||
env: {
|
||||
test: {
|
||||
plugins: ['istanbul']
|
||||
},
|
||||
development: {
|
||||
plugins: [process.env.ENV !== 'browser' && 'source-map-support'].filter(
|
||||
Boolean
|
||||
)
|
||||
},
|
||||
module: {
|
||||
presets: [['@babel/env', { modules: false }]]
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
65
node_modules/@jimp/plugin-fisheye/dist/index.js
generated
vendored
Normal file
65
node_modules/@jimp/plugin-fisheye/dist/index.js
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports["default"] = void 0;
|
||||
|
||||
var _utils = require("@jimp/utils");
|
||||
|
||||
/**
|
||||
* Creates a circle out of an image.
|
||||
* @param {object} options (optional) r: radius of effect
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
var _default = function _default() {
|
||||
return {
|
||||
fisheye: function fisheye() {
|
||||
var _this = this;
|
||||
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
||||
r: 2.5
|
||||
};
|
||||
var cb = arguments.length > 1 ? arguments[1] : undefined;
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
exports["default"] = _default;
|
||||
module.exports = exports.default;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@jimp/plugin-fisheye/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@jimp/plugin-fisheye/dist/index.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../src/index.js"],"names":["fisheye","options","r","cb","source","cloneQuiet","bitmap","width","height","scanQuiet","x","y","hx","hy","Math","sqrt","pow","rn","cosA","sinA","newX","round","newY","color","getPixelColor","setPixelColor","call"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;eAMe;AAAA,SAAO;AACpBA,IAAAA,OADoB,qBACc;AAAA;;AAAA,UAA1BC,OAA0B,uEAAhB;AAAEC,QAAAA,CAAC,EAAE;AAAL,OAAgB;AAAA,UAAJC,EAAI;;AAChC,UAAI,OAAOF,OAAP,KAAmB,UAAvB,EAAmC;AACjCE,QAAAA,EAAE,GAAGF,OAAL;AACAA,QAAAA,OAAO,GAAG;AAAEC,UAAAA,CAAC,EAAE;AAAL,SAAV;AACD;;AAED,UAAME,MAAM,GAAG,KAAKC,UAAL,EAAf;AANgC,2BAOND,MAAM,CAACE,MAPD;AAAA,UAOxBC,KAPwB,kBAOxBA,KAPwB;AAAA,UAOjBC,MAPiB,kBAOjBA,MAPiB;AAShCJ,MAAAA,MAAM,CAACK,SAAP,CAAiB,CAAjB,EAAoB,CAApB,EAAuBF,KAAvB,EAA8BC,MAA9B,EAAsC,UAACE,CAAD,EAAIC,CAAJ,EAAU;AAC9C,YAAMC,EAAE,GAAGF,CAAC,GAAGH,KAAf;AACA,YAAMM,EAAE,GAAGF,CAAC,GAAGH,MAAf;AACA,YAAMN,CAAC,GAAGY,IAAI,CAACC,IAAL,CAAUD,IAAI,CAACE,GAAL,CAASJ,EAAE,GAAG,GAAd,EAAmB,CAAnB,IAAwBE,IAAI,CAACE,GAAL,CAASH,EAAE,GAAG,GAAd,EAAmB,CAAnB,CAAlC,CAAV;AACA,YAAMI,EAAE,GAAG,IAAIH,IAAI,CAACE,GAAL,CAASd,CAAT,EAAYD,OAAO,CAACC,CAApB,CAAf;AACA,YAAMgB,IAAI,GAAG,CAACN,EAAE,GAAG,GAAN,IAAaV,CAA1B;AACA,YAAMiB,IAAI,GAAG,CAACN,EAAE,GAAG,GAAN,IAAaX,CAA1B;AACA,YAAMkB,IAAI,GAAGN,IAAI,CAACO,KAAL,CAAW,CAACJ,EAAE,GAAGC,IAAL,GAAY,GAAb,IAAoBX,KAA/B,CAAb;AACA,YAAMe,IAAI,GAAGR,IAAI,CAACO,KAAL,CAAW,CAACJ,EAAE,GAAGE,IAAL,GAAY,GAAb,IAAoBX,MAA/B,CAAb;AACA,YAAMe,KAAK,GAAGnB,MAAM,CAACoB,aAAP,CAAqBJ,IAArB,EAA2BE,IAA3B,CAAd;;AAEA,QAAA,KAAI,CAACG,aAAL,CAAmBF,KAAnB,EAA0Bb,CAA1B,EAA6BC,CAA7B;AACD,OAZD;AAcA;;AACA,WAAKc,aAAL,CACErB,MAAM,CAACoB,aAAP,CAAqBjB,KAAK,GAAG,CAA7B,EAAgCC,MAAM,GAAG,CAAzC,CADF,EAEED,KAAK,GAAG,CAFV,EAGEC,MAAM,GAAG,CAHX;;AAMA,UAAI,0BAAcL,EAAd,CAAJ,EAAuB;AACrBA,QAAAA,EAAE,CAACuB,IAAH,CAAQ,IAAR,EAAc,IAAd,EAAoB,IAApB;AACD;;AAED,aAAO,IAAP;AACD;AApCmB,GAAP;AAAA,C","sourcesContent":["import { isNodePattern } from '@jimp/utils';\n\n/**\n * Creates a circle out of an image.\n * @param {object} options (optional) r: radius of effect\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {Jimp} this for chaining of methods\n */\nexport default () => ({\n fisheye(options = { r: 2.5 }, cb) {\n if (typeof options === 'function') {\n cb = options;\n options = { r: 2.5 };\n }\n\n const source = this.cloneQuiet();\n const { width, height } = source.bitmap;\n\n source.scanQuiet(0, 0, width, height, (x, y) => {\n const hx = x / width;\n const hy = y / height;\n const r = Math.sqrt(Math.pow(hx - 0.5, 2) + Math.pow(hy - 0.5, 2));\n const rn = 2 * Math.pow(r, options.r);\n const cosA = (hx - 0.5) / r;\n const sinA = (hy - 0.5) / r;\n const newX = Math.round((rn * cosA + 0.5) * width);\n const newY = Math.round((rn * sinA + 0.5) * height);\n const color = source.getPixelColor(newX, newY);\n\n this.setPixelColor(color, x, y);\n });\n\n /* Set center pixel color, otherwise it will be transparent */\n this.setPixelColor(\n source.getPixelColor(width / 2, height / 2),\n width / 2,\n height / 2\n );\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n }\n});\n"],"file":"index.js"}
|
64
node_modules/@jimp/plugin-fisheye/es/index.js
generated
vendored
Normal file
64
node_modules/@jimp/plugin-fisheye/es/index.js
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports["default"] = void 0;
|
||||
|
||||
var _utils = require("@jimp/utils");
|
||||
|
||||
/**
|
||||
* Creates a circle out of an image.
|
||||
* @param {object} options (optional) r: radius of effect
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
var _default = function _default() {
|
||||
return {
|
||||
fisheye: function fisheye() {
|
||||
var _this = this;
|
||||
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
||||
r: 2.5
|
||||
};
|
||||
var cb = arguments.length > 1 ? arguments[1] : undefined;
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
exports["default"] = _default;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@jimp/plugin-fisheye/es/index.js.map
generated
vendored
Normal file
1
node_modules/@jimp/plugin-fisheye/es/index.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../src/index.js"],"names":["fisheye","options","r","cb","source","cloneQuiet","bitmap","width","height","scanQuiet","x","y","hx","hy","Math","sqrt","pow","rn","cosA","sinA","newX","round","newY","color","getPixelColor","setPixelColor","call"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;eAMe;AAAA,SAAO;AACpBA,IAAAA,OADoB,qBACc;AAAA;;AAAA,UAA1BC,OAA0B,uEAAhB;AAAEC,QAAAA,CAAC,EAAE;AAAL,OAAgB;AAAA,UAAJC,EAAI;;AAChC,UAAI,OAAOF,OAAP,KAAmB,UAAvB,EAAmC;AACjCE,QAAAA,EAAE,GAAGF,OAAL;AACAA,QAAAA,OAAO,GAAG;AAAEC,UAAAA,CAAC,EAAE;AAAL,SAAV;AACD;;AAED,UAAME,MAAM,GAAG,KAAKC,UAAL,EAAf;AANgC,2BAOND,MAAM,CAACE,MAPD;AAAA,UAOxBC,KAPwB,kBAOxBA,KAPwB;AAAA,UAOjBC,MAPiB,kBAOjBA,MAPiB;AAShCJ,MAAAA,MAAM,CAACK,SAAP,CAAiB,CAAjB,EAAoB,CAApB,EAAuBF,KAAvB,EAA8BC,MAA9B,EAAsC,UAACE,CAAD,EAAIC,CAAJ,EAAU;AAC9C,YAAMC,EAAE,GAAGF,CAAC,GAAGH,KAAf;AACA,YAAMM,EAAE,GAAGF,CAAC,GAAGH,MAAf;AACA,YAAMN,CAAC,GAAGY,IAAI,CAACC,IAAL,CAAUD,IAAI,CAACE,GAAL,CAASJ,EAAE,GAAG,GAAd,EAAmB,CAAnB,IAAwBE,IAAI,CAACE,GAAL,CAASH,EAAE,GAAG,GAAd,EAAmB,CAAnB,CAAlC,CAAV;AACA,YAAMI,EAAE,GAAG,IAAIH,IAAI,CAACE,GAAL,CAASd,CAAT,EAAYD,OAAO,CAACC,CAApB,CAAf;AACA,YAAMgB,IAAI,GAAG,CAACN,EAAE,GAAG,GAAN,IAAaV,CAA1B;AACA,YAAMiB,IAAI,GAAG,CAACN,EAAE,GAAG,GAAN,IAAaX,CAA1B;AACA,YAAMkB,IAAI,GAAGN,IAAI,CAACO,KAAL,CAAW,CAACJ,EAAE,GAAGC,IAAL,GAAY,GAAb,IAAoBX,KAA/B,CAAb;AACA,YAAMe,IAAI,GAAGR,IAAI,CAACO,KAAL,CAAW,CAACJ,EAAE,GAAGE,IAAL,GAAY,GAAb,IAAoBX,MAA/B,CAAb;AACA,YAAMe,KAAK,GAAGnB,MAAM,CAACoB,aAAP,CAAqBJ,IAArB,EAA2BE,IAA3B,CAAd;;AAEA,QAAA,KAAI,CAACG,aAAL,CAAmBF,KAAnB,EAA0Bb,CAA1B,EAA6BC,CAA7B;AACD,OAZD;AAcA;;AACA,WAAKc,aAAL,CACErB,MAAM,CAACoB,aAAP,CAAqBjB,KAAK,GAAG,CAA7B,EAAgCC,MAAM,GAAG,CAAzC,CADF,EAEED,KAAK,GAAG,CAFV,EAGEC,MAAM,GAAG,CAHX;;AAMA,UAAI,0BAAcL,EAAd,CAAJ,EAAuB;AACrBA,QAAAA,EAAE,CAACuB,IAAH,CAAQ,IAAR,EAAc,IAAd,EAAoB,IAApB;AACD;;AAED,aAAO,IAAP;AACD;AApCmB,GAAP;AAAA,C","sourcesContent":["import { isNodePattern } from '@jimp/utils';\n\n/**\n * Creates a circle out of an image.\n * @param {object} options (optional) r: radius of effect\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {Jimp} this for chaining of methods\n */\nexport default () => ({\n fisheye(options = { r: 2.5 }, cb) {\n if (typeof options === 'function') {\n cb = options;\n options = { r: 2.5 };\n }\n\n const source = this.cloneQuiet();\n const { width, height } = source.bitmap;\n\n source.scanQuiet(0, 0, width, height, (x, y) => {\n const hx = x / width;\n const hy = y / height;\n const r = Math.sqrt(Math.pow(hx - 0.5, 2) + Math.pow(hy - 0.5, 2));\n const rn = 2 * Math.pow(r, options.r);\n const cosA = (hx - 0.5) / r;\n const sinA = (hy - 0.5) / r;\n const newX = Math.round((rn * cosA + 0.5) * width);\n const newY = Math.round((rn * sinA + 0.5) * height);\n const color = source.getPixelColor(newX, newY);\n\n this.setPixelColor(color, x, y);\n });\n\n /* Set center pixel color, otherwise it will be transparent */\n this.setPixelColor(\n source.getPixelColor(width / 2, height / 2),\n width / 2,\n height / 2\n );\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n }\n});\n"],"file":"index.js"}
|
8
node_modules/@jimp/plugin-fisheye/index.d.ts
generated
vendored
Normal file
8
node_modules/@jimp/plugin-fisheye/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
import { ImageCallback } from '@jimp/core';
|
||||
|
||||
interface Fisheye {
|
||||
fishEye(opts?: { r: number }, cb?: ImageCallback<this>): this;
|
||||
fishEye(cb?: ImageCallback<this>): this;
|
||||
}
|
||||
|
||||
export default function(): Fisheye;
|
37
node_modules/@jimp/plugin-fisheye/package.json
generated
vendored
Normal file
37
node_modules/@jimp/plugin-fisheye/package.json
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "@jimp/plugin-fisheye",
|
||||
"version": "0.12.1",
|
||||
"description": "Apply a fisheye effect to an image.",
|
||||
"main": "dist/index.js",
|
||||
"module": "es/index.js",
|
||||
"types": "index.d.ts",
|
||||
"scripts": {
|
||||
"test": "cross-env BABEL_ENV=test mocha --require @babel/register",
|
||||
"test:watch": "npm run test -- --reporter min --watch",
|
||||
"test:coverage": "nyc npm run test",
|
||||
"build": "npm run build:node:production && npm run build:module",
|
||||
"build:watch": "npm run build:node:debug -- -- --watch --verbose",
|
||||
"build:debug": "npm run build:node:debug",
|
||||
"build:module": "cross-env BABEL_ENV=module babel src -d es --source-maps --config-file ../../babel.config.js",
|
||||
"build:node": "babel src -d dist --source-maps --config-file ../../babel.config.js",
|
||||
"build:node:debug": "cross-env BABEL_ENV=development npm run build:node",
|
||||
"build:node:production": "cross-env BABEL_ENV=production npm run build:node"
|
||||
},
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.7.2",
|
||||
"@jimp/utils": "^0.12.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@jimp/custom": ">=0.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jimp/custom": "^0.12.1",
|
||||
"@jimp/test-utils": "^0.12.1"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "942e635564e36fc243767531b4f8be036afa40b5"
|
||||
}
|
46
node_modules/@jimp/plugin-fisheye/src/index.js
generated
vendored
Normal file
46
node_modules/@jimp/plugin-fisheye/src/index.js
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
import { isNodePattern } from '@jimp/utils';
|
||||
|
||||
/**
|
||||
* Creates a circle out of an image.
|
||||
* @param {object} options (optional) r: radius of effect
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
export default () => ({
|
||||
fisheye(options = { r: 2.5 }, cb) {
|
||||
if (typeof options === 'function') {
|
||||
cb = options;
|
||||
options = { r: 2.5 };
|
||||
}
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
80
node_modules/@jimp/plugin-fisheye/test/fisheye.test.js
generated
vendored
Normal file
80
node_modules/@jimp/plugin-fisheye/test/fisheye.test.js
generated
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
import { Jimp, mkJGD } from '@jimp/test-utils';
|
||||
import configure from '@jimp/custom';
|
||||
|
||||
import fisheye from '../src';
|
||||
|
||||
const jimp = configure({ plugins: [fisheye] }, Jimp);
|
||||
|
||||
describe('Fisheye', () => {
|
||||
it('should create fisheye lens to image', async () => {
|
||||
const imgNormal = await jimp.read(
|
||||
mkJGD(
|
||||
'0000000000',
|
||||
'0001221000',
|
||||
'0022222200',
|
||||
'0122112210',
|
||||
'0221001220',
|
||||
'0221001220',
|
||||
'0122112210',
|
||||
'0022222200',
|
||||
'0001221000',
|
||||
'0000000000'
|
||||
)
|
||||
);
|
||||
const imgBulged = await jimp.read(
|
||||
mkJGD(
|
||||
'0001221000',
|
||||
'0221112220',
|
||||
'0220000121',
|
||||
'1100000112',
|
||||
'2100000012',
|
||||
'2100000012',
|
||||
'1200000012',
|
||||
'0211000222',
|
||||
'0221111220',
|
||||
'0012222200'
|
||||
)
|
||||
);
|
||||
|
||||
imgNormal
|
||||
.fisheye()
|
||||
.getJGDSync()
|
||||
.should.be.sameJGD(imgBulged.getJGDSync());
|
||||
});
|
||||
|
||||
it('should create fisheye lens to image with radius', async () => {
|
||||
const imgNormal = await jimp.read(
|
||||
mkJGD(
|
||||
'0000000000',
|
||||
'0000000000',
|
||||
'0000000000',
|
||||
'0000000000',
|
||||
'0001111000',
|
||||
'0001111000',
|
||||
'0000000000',
|
||||
'0000000000',
|
||||
'0000000000',
|
||||
'0000000000'
|
||||
)
|
||||
);
|
||||
const imgBulged = await jimp.read(
|
||||
mkJGD(
|
||||
'■■■■■■■■■■',
|
||||
'■■■■■■■■■■',
|
||||
'■■■■■■■■■■',
|
||||
'■■■11111■■',
|
||||
'■■111111■■',
|
||||
'■■111111■■',
|
||||
'■■■■111■■■',
|
||||
'■■■■■■■■■■',
|
||||
'■■■■■■■■■■',
|
||||
'■■■■■■■■■■'
|
||||
)
|
||||
);
|
||||
|
||||
imgNormal
|
||||
.fisheye({ r: 1.8 })
|
||||
.getJGDSync()
|
||||
.should.be.sameJGD(imgBulged.getJGDSync());
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user