chore: add jimp dependency, icon padding script, and update configuration
This commit is contained in:
+85
@@ -0,0 +1,85 @@
|
||||
# v0.22.1 (Mon Feb 06 2023)
|
||||
|
||||
#### 🏠 Internal
|
||||
|
||||
- rename master to main [#1169](https://github.com/jimp-dev/jimp/pull/1169) ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
---
|
||||
|
||||
# v0.22.0 (Mon Feb 06 2023)
|
||||
|
||||
#### 🏠 Internal
|
||||
|
||||
- switch from should to expect [#1163](https://github.com/jimp-dev/jimp/pull/1163) ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
- Change test matching strategy to include all test files [#1161](https://github.com/jimp-dev/jimp/pull/1161) ([@danielholmes](https://github.com/danielholmes))
|
||||
|
||||
#### Authors: 2
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
- Daniel Holmes ([@danielholmes](https://github.com/danielholmes))
|
||||
|
||||
---
|
||||
|
||||
# v0.21.0 (Sun Feb 05 2023)
|
||||
|
||||
### Release Notes
|
||||
|
||||
#### Babel Refactor ([#1149](https://github.com/jimp-dev/jimp/pull/1149))
|
||||
|
||||
Marking this as a "breaking release" because it might change what deps need to be installed.
|
||||
|
||||
All modules should be exported as valid cjs and esm
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
#### 💥 Breaking Change
|
||||
|
||||
- Babel Refactor [#1149](https://github.com/jimp-dev/jimp/pull/1149) ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
---
|
||||
|
||||
# v0.16.3 (Sat Feb 04 2023)
|
||||
|
||||
#### ⚠️ Pushed to `main`
|
||||
|
||||
- upgrade prettier ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
---
|
||||
|
||||
# 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
@@ -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.
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
<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-circle</h1>
|
||||
<p>Creates a circle out of an image.</p>
|
||||
</div>
|
||||
|
||||
## Usage
|
||||
|
||||
- @param {function(Error, Jimp)} options (optional) radius, x, y
|
||||
- @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.circle();
|
||||
// or
|
||||
image.circle({ radius: 50, x: 25, y: 25 });
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
import { isNodePattern } from "@jimp/utils";
|
||||
|
||||
/**
|
||||
* Creates a circle out of an image.
|
||||
* @param {function(Error, Jimp)} options (optional) radius, x, y
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
export default (() => ({
|
||||
circle() {
|
||||
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
let cb = arguments.length > 1 ? arguments[1] : undefined;
|
||||
if (typeof options === "function") {
|
||||
cb = options;
|
||||
options = {};
|
||||
}
|
||||
const radius = options.radius || (this.bitmap.width > this.bitmap.height ? this.bitmap.height : this.bitmap.width) / 2;
|
||||
const center = {
|
||||
x: typeof options.x === "number" ? options.x : this.bitmap.width / 2,
|
||||
y: typeof options.y === "number" ? options.y : this.bitmap.height / 2
|
||||
};
|
||||
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {
|
||||
const curR = Math.sqrt(Math.pow(x - center.x, 2) + Math.pow(y - center.y, 2));
|
||||
if (radius - curR <= 0.0) {
|
||||
this.bitmap.data[idx + 3] = 0;
|
||||
} else if (radius - curR < 1.0) {
|
||||
this.bitmap.data[idx + 3] = 255 * (radius - curR);
|
||||
}
|
||||
});
|
||||
if (isNodePattern(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}));
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":["isNodePattern","circle","options","cb","radius","bitmap","width","height","center","x","y","scanQuiet","idx","curR","Math","sqrt","pow","data","call"],"sources":["../src/index.js"],"sourcesContent":["import { isNodePattern } from \"@jimp/utils\";\n\n/**\n * Creates a circle out of an image.\n * @param {function(Error, Jimp)} options (optional) radius, x, y\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {Jimp} this for chaining of methods\n */\nexport default () => ({\n circle(options = {}, cb) {\n if (typeof options === \"function\") {\n cb = options;\n options = {};\n }\n\n const radius =\n options.radius ||\n (this.bitmap.width > this.bitmap.height\n ? this.bitmap.height\n : this.bitmap.width) / 2;\n\n const center = {\n x: typeof options.x === \"number\" ? options.x : this.bitmap.width / 2,\n y: typeof options.y === \"number\" ? options.y : this.bitmap.height / 2,\n };\n\n this.scanQuiet(\n 0,\n 0,\n this.bitmap.width,\n this.bitmap.height,\n function (x, y, idx) {\n const curR = Math.sqrt(\n Math.pow(x - center.x, 2) + Math.pow(y - center.y, 2)\n );\n\n if (radius - curR <= 0.0) {\n this.bitmap.data[idx + 3] = 0;\n } else if (radius - curR < 1.0) {\n this.bitmap.data[idx + 3] = 255 * (radius - curR);\n }\n }\n );\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n },\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,aAAa;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;EACpBC,MAAM,GAAmB;IAAA,IAAlBC,OAAO,uEAAG,CAAC,CAAC;IAAA,IAAEC,EAAE;IACrB,IAAI,OAAOD,OAAO,KAAK,UAAU,EAAE;MACjCC,EAAE,GAAGD,OAAO;MACZA,OAAO,GAAG,CAAC,CAAC;IACd;IAEA,MAAME,MAAM,GACVF,OAAO,CAACE,MAAM,IACd,CAAC,IAAI,CAACC,MAAM,CAACC,KAAK,GAAG,IAAI,CAACD,MAAM,CAACE,MAAM,GACnC,IAAI,CAACF,MAAM,CAACE,MAAM,GAClB,IAAI,CAACF,MAAM,CAACC,KAAK,IAAI,CAAC;IAE5B,MAAME,MAAM,GAAG;MACbC,CAAC,EAAE,OAAOP,OAAO,CAACO,CAAC,KAAK,QAAQ,GAAGP,OAAO,CAACO,CAAC,GAAG,IAAI,CAACJ,MAAM,CAACC,KAAK,GAAG,CAAC;MACpEI,CAAC,EAAE,OAAOR,OAAO,CAACQ,CAAC,KAAK,QAAQ,GAAGR,OAAO,CAACQ,CAAC,GAAG,IAAI,CAACL,MAAM,CAACE,MAAM,GAAG;IACtE,CAAC;IAED,IAAI,CAACI,SAAS,CACZ,CAAC,EACD,CAAC,EACD,IAAI,CAACN,MAAM,CAACC,KAAK,EACjB,IAAI,CAACD,MAAM,CAACE,MAAM,EAClB,UAAUE,CAAC,EAAEC,CAAC,EAAEE,GAAG,EAAE;MACnB,MAAMC,IAAI,GAAGC,IAAI,CAACC,IAAI,CACpBD,IAAI,CAACE,GAAG,CAACP,CAAC,GAAGD,MAAM,CAACC,CAAC,EAAE,CAAC,CAAC,GAAGK,IAAI,CAACE,GAAG,CAACN,CAAC,GAAGF,MAAM,CAACE,CAAC,EAAE,CAAC,CAAC,CACtD;MAED,IAAIN,MAAM,GAAGS,IAAI,IAAI,GAAG,EAAE;QACxB,IAAI,CAACR,MAAM,CAACY,IAAI,CAACL,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC;MAC/B,CAAC,MAAM,IAAIR,MAAM,GAAGS,IAAI,GAAG,GAAG,EAAE;QAC9B,IAAI,CAACR,MAAM,CAACY,IAAI,CAACL,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,IAAIR,MAAM,GAAGS,IAAI,CAAC;MACnD;IACF,CAAC,CACF;IAED,IAAIb,aAAa,CAACG,EAAE,CAAC,EAAE;MACrBA,EAAE,CAACe,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;IAC3B;IAEA,OAAO,IAAI;EACb;AACF,CAAC,CAAC"}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import { ImageCallback } from "@jimp/core";
|
||||
|
||||
interface Circle {
|
||||
circle(
|
||||
options?: {
|
||||
radius: number;
|
||||
x: number;
|
||||
y: number;
|
||||
},
|
||||
cb?: ImageCallback<this>
|
||||
): this;
|
||||
circle(cb?: ImageCallback<this>): this;
|
||||
}
|
||||
|
||||
export default function (): Circle;
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "@jimp/plugin-circle",
|
||||
"version": "0.22.12",
|
||||
"description": "Creates a circle out of an image.",
|
||||
"main": "dist/index.js",
|
||||
"module": "es/index.js",
|
||||
"repository": "jimp-dev/jimp",
|
||||
"types": "index.d.ts",
|
||||
"scripts": {
|
||||
"test": "cross-env BABEL_ENV=test mocha --require @babel/register --recursive test --extension js",
|
||||
"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": {
|
||||
"@jimp/utils": "^0.22.12"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@jimp/custom": ">=0.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jimp/custom": "^0.22.12",
|
||||
"@jimp/test-utils": "^0.22.12"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "a4a8d6364bbf97629749e196f3b0a4c94c9a7abc"
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
import { isNodePattern } from "@jimp/utils";
|
||||
|
||||
/**
|
||||
* Creates a circle out of an image.
|
||||
* @param {function(Error, Jimp)} options (optional) radius, x, y
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
export default () => ({
|
||||
circle(options = {}, cb) {
|
||||
if (typeof options === "function") {
|
||||
cb = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
const radius =
|
||||
options.radius ||
|
||||
(this.bitmap.width > this.bitmap.height
|
||||
? this.bitmap.height
|
||||
: this.bitmap.width) / 2;
|
||||
|
||||
const center = {
|
||||
x: typeof options.x === "number" ? options.x : this.bitmap.width / 2,
|
||||
y: typeof options.y === "number" ? options.y : this.bitmap.height / 2,
|
||||
};
|
||||
|
||||
this.scanQuiet(
|
||||
0,
|
||||
0,
|
||||
this.bitmap.width,
|
||||
this.bitmap.height,
|
||||
function (x, y, idx) {
|
||||
const curR = Math.sqrt(
|
||||
Math.pow(x - center.x, 2) + Math.pow(y - center.y, 2)
|
||||
);
|
||||
|
||||
if (radius - curR <= 0.0) {
|
||||
this.bitmap.data[idx + 3] = 0;
|
||||
} else if (radius - curR < 1.0) {
|
||||
this.bitmap.data[idx + 3] = 255 * (radius - curR);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (isNodePattern(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
});
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
import { Jimp, mkJGD, getTestDir } from "@jimp/test-utils";
|
||||
import configure from "@jimp/custom";
|
||||
import expect from "@storybook/expect";
|
||||
|
||||
import circle from "../src";
|
||||
|
||||
const jimp = configure({ plugins: [circle] }, Jimp);
|
||||
|
||||
describe("Circle", () => {
|
||||
it("makes a circle based on image height and width", async () => {
|
||||
const expectedImg = await Jimp.read(
|
||||
getTestDir(__dirname) + "/images/circled.png"
|
||||
);
|
||||
const imgSrc = await jimp.read(
|
||||
mkJGD(
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦"
|
||||
)
|
||||
);
|
||||
|
||||
expect(imgSrc.circle().bitmap.data).toEqual(expectedImg.bitmap.data);
|
||||
});
|
||||
|
||||
it("makes a circle using provided radius", async () => {
|
||||
const expectedImg = await Jimp.read(
|
||||
getTestDir(__dirname) + "/images/radius-3-circle.png"
|
||||
);
|
||||
const imgSrc = await jimp.read(
|
||||
mkJGD(
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦"
|
||||
)
|
||||
);
|
||||
|
||||
expect(imgSrc.circle({ radius: 3 }).bitmap.data).toEqual(
|
||||
expectedImg.bitmap.data
|
||||
);
|
||||
});
|
||||
|
||||
it("should ", async () => {
|
||||
const expectedImg = await Jimp.read(
|
||||
getTestDir(__dirname) + "/images/x-y-circle.png"
|
||||
);
|
||||
const imgSrc = await jimp.read(
|
||||
mkJGD(
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦",
|
||||
"▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦"
|
||||
)
|
||||
);
|
||||
|
||||
expect(imgSrc.circle({ radius: 5, x: 5, y: 5 }).bitmap.data).toEqual(
|
||||
expectedImg.bitmap.data
|
||||
);
|
||||
});
|
||||
});
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 177 B |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 141 B |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 180 B |
Reference in New Issue
Block a user