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.
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<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-mask</h1>
|
||||
<p>mask an image with another image.</p>
|
||||
</div>
|
||||
|
||||
Masks a source image on to this image using average pixel colour. A completely black pixel on the mask will turn a pixel in the image completely transparent.
|
||||
|
||||
## Usage
|
||||
|
||||
- @param {Jimp} src the source Jimp instance
|
||||
- @param {number} x the horizontal position to blit the image
|
||||
- @param {number} y the vertical position to blit the image
|
||||
- @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");
|
||||
const mask = await jimp.read("test/mask.png");
|
||||
|
||||
image.mask(mask);
|
||||
}
|
||||
```
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
import { isNodePattern, throwError } from "@jimp/utils";
|
||||
|
||||
/**
|
||||
* Masks a source image on to this image using average pixel colour. A completely black pixel on the mask will turn a pixel in the image completely transparent.
|
||||
* @param {Jimp} src the source Jimp instance
|
||||
* @param {number} x the horizontal position to blit the image
|
||||
* @param {number} y the vertical position to blit the image
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
export default (() => ({
|
||||
mask(src) {
|
||||
let x = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
||||
let y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
||||
let cb = arguments.length > 3 ? arguments[3] : undefined;
|
||||
if (!(src instanceof this.constructor)) {
|
||||
return throwError.call(this, "The source must be a Jimp image", cb);
|
||||
}
|
||||
if (typeof x !== "number" || typeof y !== "number") {
|
||||
return throwError.call(this, "x and y must be numbers", cb);
|
||||
}
|
||||
|
||||
// round input
|
||||
x = Math.round(x);
|
||||
y = Math.round(y);
|
||||
const w = this.bitmap.width;
|
||||
const h = this.bitmap.height;
|
||||
const baseImage = this;
|
||||
src.scanQuiet(0, 0, src.bitmap.width, src.bitmap.height, function (sx, sy, idx) {
|
||||
const destX = x + sx;
|
||||
const destY = y + sy;
|
||||
if (destX >= 0 && destY >= 0 && destX < w && destY < h) {
|
||||
const dstIdx = baseImage.getPixelIndex(destX, destY);
|
||||
const {
|
||||
data
|
||||
} = this.bitmap;
|
||||
const avg = (data[idx + 0] + data[idx + 1] + data[idx + 2]) / 3;
|
||||
baseImage.bitmap.data[dstIdx + 3] *= avg / 255;
|
||||
}
|
||||
});
|
||||
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","throwError","mask","src","x","y","cb","constructor","call","Math","round","w","bitmap","width","h","height","baseImage","scanQuiet","sx","sy","idx","destX","destY","dstIdx","getPixelIndex","data","avg"],"sources":["../src/index.js"],"sourcesContent":["import { isNodePattern, throwError } from \"@jimp/utils\";\n\n/**\n * Masks a source image on to this image using average pixel colour. A completely black pixel on the mask will turn a pixel in the image completely transparent.\n * @param {Jimp} src the source Jimp instance\n * @param {number} x the horizontal position to blit the image\n * @param {number} y the vertical position to blit the image\n * @param {function(Error, Jimp)} cb (optional) a callback for when complete\n * @returns {Jimp} this for chaining of methods\n */\nexport default () => ({\n mask(src, x = 0, y = 0, cb) {\n if (!(src instanceof this.constructor)) {\n return throwError.call(this, \"The source must be a Jimp image\", cb);\n }\n\n if (typeof x !== \"number\" || typeof y !== \"number\") {\n return throwError.call(this, \"x and y must be numbers\", cb);\n }\n\n // round input\n x = Math.round(x);\n y = Math.round(y);\n\n const w = this.bitmap.width;\n const h = this.bitmap.height;\n const baseImage = this;\n\n src.scanQuiet(\n 0,\n 0,\n src.bitmap.width,\n src.bitmap.height,\n function (sx, sy, idx) {\n const destX = x + sx;\n const destY = y + sy;\n\n if (destX >= 0 && destY >= 0 && destX < w && destY < h) {\n const dstIdx = baseImage.getPixelIndex(destX, destY);\n const { data } = this.bitmap;\n const avg = (data[idx + 0] + data[idx + 1] + data[idx + 2]) / 3;\n\n baseImage.bitmap.data[dstIdx + 3] *= avg / 255;\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,EAAEC,UAAU,QAAQ,aAAa;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;EACpBC,IAAI,CAACC,GAAG,EAAoB;IAAA,IAAlBC,CAAC,uEAAG,CAAC;IAAA,IAAEC,CAAC,uEAAG,CAAC;IAAA,IAAEC,EAAE;IACxB,IAAI,EAAEH,GAAG,YAAY,IAAI,CAACI,WAAW,CAAC,EAAE;MACtC,OAAON,UAAU,CAACO,IAAI,CAAC,IAAI,EAAE,iCAAiC,EAAEF,EAAE,CAAC;IACrE;IAEA,IAAI,OAAOF,CAAC,KAAK,QAAQ,IAAI,OAAOC,CAAC,KAAK,QAAQ,EAAE;MAClD,OAAOJ,UAAU,CAACO,IAAI,CAAC,IAAI,EAAE,yBAAyB,EAAEF,EAAE,CAAC;IAC7D;;IAEA;IACAF,CAAC,GAAGK,IAAI,CAACC,KAAK,CAACN,CAAC,CAAC;IACjBC,CAAC,GAAGI,IAAI,CAACC,KAAK,CAACL,CAAC,CAAC;IAEjB,MAAMM,CAAC,GAAG,IAAI,CAACC,MAAM,CAACC,KAAK;IAC3B,MAAMC,CAAC,GAAG,IAAI,CAACF,MAAM,CAACG,MAAM;IAC5B,MAAMC,SAAS,GAAG,IAAI;IAEtBb,GAAG,CAACc,SAAS,CACX,CAAC,EACD,CAAC,EACDd,GAAG,CAACS,MAAM,CAACC,KAAK,EAChBV,GAAG,CAACS,MAAM,CAACG,MAAM,EACjB,UAAUG,EAAE,EAAEC,EAAE,EAAEC,GAAG,EAAE;MACrB,MAAMC,KAAK,GAAGjB,CAAC,GAAGc,EAAE;MACpB,MAAMI,KAAK,GAAGjB,CAAC,GAAGc,EAAE;MAEpB,IAAIE,KAAK,IAAI,CAAC,IAAIC,KAAK,IAAI,CAAC,IAAID,KAAK,GAAGV,CAAC,IAAIW,KAAK,GAAGR,CAAC,EAAE;QACtD,MAAMS,MAAM,GAAGP,SAAS,CAACQ,aAAa,CAACH,KAAK,EAAEC,KAAK,CAAC;QACpD,MAAM;UAAEG;QAAK,CAAC,GAAG,IAAI,CAACb,MAAM;QAC5B,MAAMc,GAAG,GAAG,CAACD,IAAI,CAACL,GAAG,GAAG,CAAC,CAAC,GAAGK,IAAI,CAACL,GAAG,GAAG,CAAC,CAAC,GAAGK,IAAI,CAACL,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC;QAE/DJ,SAAS,CAACJ,MAAM,CAACa,IAAI,CAACF,MAAM,GAAG,CAAC,CAAC,IAAIG,GAAG,GAAG,GAAG;MAChD;IACF,CAAC,CACF;IAED,IAAI1B,aAAa,CAACM,EAAE,CAAC,EAAE;MACrBA,EAAE,CAACE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;IAC3B;IAEA,OAAO,IAAI;EACb;AACF,CAAC,CAAC"}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { ImageCallback, Jimp } from "@jimp/core";
|
||||
|
||||
interface Mask {
|
||||
mask(src: Jimp, x: number, y: number, cb?: ImageCallback<this>): this;
|
||||
}
|
||||
|
||||
export default function (): Mask;
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "@jimp/plugin-mask",
|
||||
"version": "0.22.12",
|
||||
"description": "mask 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"
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
import { isNodePattern, throwError } from "@jimp/utils";
|
||||
|
||||
/**
|
||||
* Masks a source image on to this image using average pixel colour. A completely black pixel on the mask will turn a pixel in the image completely transparent.
|
||||
* @param {Jimp} src the source Jimp instance
|
||||
* @param {number} x the horizontal position to blit the image
|
||||
* @param {number} y the vertical position to blit the image
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
export default () => ({
|
||||
mask(src, x = 0, y = 0, cb) {
|
||||
if (!(src instanceof this.constructor)) {
|
||||
return throwError.call(this, "The source must be a Jimp image", cb);
|
||||
}
|
||||
|
||||
if (typeof x !== "number" || typeof y !== "number") {
|
||||
return throwError.call(this, "x and y must be numbers", cb);
|
||||
}
|
||||
|
||||
// round input
|
||||
x = Math.round(x);
|
||||
y = Math.round(y);
|
||||
|
||||
const w = this.bitmap.width;
|
||||
const h = this.bitmap.height;
|
||||
const baseImage = this;
|
||||
|
||||
src.scanQuiet(
|
||||
0,
|
||||
0,
|
||||
src.bitmap.width,
|
||||
src.bitmap.height,
|
||||
function (sx, sy, idx) {
|
||||
const destX = x + sx;
|
||||
const destY = y + sy;
|
||||
|
||||
if (destX >= 0 && destY >= 0 && destX < w && destY < h) {
|
||||
const dstIdx = baseImage.getPixelIndex(destX, destY);
|
||||
const { data } = this.bitmap;
|
||||
const avg = (data[idx + 0] + data[idx + 1] + data[idx + 2]) / 3;
|
||||
|
||||
baseImage.bitmap.data[dstIdx + 3] *= avg / 255;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (isNodePattern(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
});
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
import { Jimp, mkJGD } from "@jimp/test-utils";
|
||||
import configure from "@jimp/custom";
|
||||
|
||||
import mask from "../src";
|
||||
import { expectToBeJGD } from "@jimp/test-utils/src";
|
||||
|
||||
const jimp = configure({ plugins: [mask] }, Jimp);
|
||||
|
||||
describe("Mask", () => {
|
||||
let imgSrcOpaq;
|
||||
let imgSrcAlpa;
|
||||
let maskGrayBig;
|
||||
let maskGraySmall;
|
||||
let maskColor;
|
||||
|
||||
before((done) => {
|
||||
Promise.all([
|
||||
jimp.read(mkJGD("▴□▾□■□", "■▴■▾■□", "■□▴□▾□", "■□■▴■▾")),
|
||||
jimp.read(mkJGD("▴▵▾▿", "▴▵▾▿", "▴▵▾▿")),
|
||||
jimp.read(mkJGD("048840", "8CFFC8", "8CFFC8", "048840")),
|
||||
jimp.read(mkJGD("0369", "369C", "69CF")),
|
||||
jimp.read(mkJGD("▴▴▾▾", "▪▪▰▰", "□□□□")),
|
||||
])
|
||||
.then((imgs) => {
|
||||
imgSrcOpaq = imgs[0];
|
||||
imgSrcAlpa = imgs[1];
|
||||
maskGrayBig = imgs[2];
|
||||
maskGraySmall = imgs[3];
|
||||
maskColor = imgs[4];
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it("Affect opaque image with a gray mask with the same size", () => {
|
||||
expectToBeJGD(imgSrcOpaq.clone().mask(maskGrayBig).getJGDSync(), {
|
||||
width: 6,
|
||||
height: 4,
|
||||
data: [
|
||||
0xff000000, 0xffffff44, 0x0000ff88, 0xffffff88, 0x00000044, 0xffffff00,
|
||||
0x00000088, 0xff0000cc, 0x000000ff, 0x0000ffff, 0x000000cc, 0xffffff88,
|
||||
0x00000088, 0xffffffcc, 0xff0000ff, 0xffffffff, 0x0000ffcc, 0xffffff88,
|
||||
0x00000000, 0xffffff44, 0x00000088, 0xff000088, 0x00000044, 0x0000ff00,
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("Affect opaque image with a gray mask with the same size, blited", () => {
|
||||
expectToBeJGD(imgSrcOpaq.clone().mask(maskGrayBig, 1, 1).getJGDSync(), {
|
||||
width: 6,
|
||||
height: 4,
|
||||
data: [
|
||||
0xff0000ff, 0xffffffff, 0x0000ffff, 0xffffffff, 0x000000ff, 0xffffffff,
|
||||
0x000000ff, 0xff000000, 0x00000044, 0x0000ff88, 0x00000088, 0xffffff44,
|
||||
0x000000ff, 0xffffff88, 0xff0000cc, 0xffffffff, 0x0000ffff, 0xffffffcc,
|
||||
0x000000ff, 0xffffff88, 0x000000cc, 0xff0000ff, 0x000000ff, 0x0000ffcc,
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("Affect opaque image with a gray mask with the same size, blited negative", () => {
|
||||
expectToBeJGD(imgSrcOpaq.clone().mask(maskGrayBig, -1, -1).getJGDSync(), {
|
||||
width: 6,
|
||||
height: 4,
|
||||
data: [
|
||||
0xff0000cc, 0xffffffff, 0x0000ffff, 0xffffffcc, 0x00000088, 0xffffffff,
|
||||
0x000000cc, 0xff0000ff, 0x000000ff, 0x0000ffcc, 0x00000088, 0xffffffff,
|
||||
0x00000044, 0xffffff88, 0xff000088, 0xffffff44, 0x0000ff00, 0xffffffff,
|
||||
0x000000ff, 0xffffffff, 0x000000ff, 0xff0000ff, 0x000000ff, 0x0000ffff,
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("Affect opaque image with a smaller gray mask", () => {
|
||||
expectToBeJGD(imgSrcOpaq.clone().mask(maskGraySmall).getJGDSync(), {
|
||||
width: 6,
|
||||
height: 4,
|
||||
data: [
|
||||
0xff000000, 0xffffff33, 0x0000ff66, 0xffffff99, 0x000000ff, 0xffffffff,
|
||||
0x00000033, 0xff000066, 0x00000099, 0x0000ffcc, 0x000000ff, 0xffffffff,
|
||||
0x00000066, 0xffffff99, 0xff0000cc, 0xffffffff, 0x0000ffff, 0xffffffff,
|
||||
0x000000ff, 0xffffffff, 0x000000ff, 0xff0000ff, 0x000000ff, 0x0000ffff,
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("Affect opaque image with a smaller gray mask, blited", () => {
|
||||
expectToBeJGD(imgSrcOpaq.clone().mask(maskGraySmall, 1, 1).getJGDSync(), {
|
||||
width: 6,
|
||||
height: 4,
|
||||
data: [
|
||||
0xff0000ff, 0xffffffff, 0x0000ffff, 0xffffffff, 0x000000ff, 0xffffffff,
|
||||
0x000000ff, 0xff000000, 0x00000033, 0x0000ff66, 0x00000099, 0xffffffff,
|
||||
0x000000ff, 0xffffff33, 0xff000066, 0xffffff99, 0x0000ffcc, 0xffffffff,
|
||||
0x000000ff, 0xffffff66, 0x00000099, 0xff0000cc, 0x000000ff, 0x0000ffff,
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("Affect alpha image with a bigger gray mask", () => {
|
||||
expectToBeJGD(imgSrcAlpa.clone().mask(maskGrayBig).getJGDSync(), {
|
||||
width: 4,
|
||||
height: 3,
|
||||
data: [
|
||||
0xff000000, 0xff000021, 0x0000ff88, 0x0000ff43, 0xff000088, 0xff000065,
|
||||
0x0000ffff, 0x0000ff7f, 0xff000088, 0xff000065, 0x0000ffff, 0x0000ff7f,
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("Affect alpha image with a bigger gray mask, blited", () => {
|
||||
expectToBeJGD(imgSrcAlpa.clone().mask(maskGrayBig, -1, -1).getJGDSync(), {
|
||||
width: 4,
|
||||
height: 3,
|
||||
data: [
|
||||
0xff0000cc, 0xff00007f, 0x0000ffff, 0x0000ff65, 0xff0000cc, 0xff00007f,
|
||||
0x0000ffff, 0x0000ff65, 0xff000044, 0xff000043, 0x0000ff88, 0x0000ff21,
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("Affect opaque image with a colored mask", () => {
|
||||
expectToBeJGD(imgSrcOpaq.clone().mask(maskColor, 1, 1).getJGDSync(), {
|
||||
width: 6,
|
||||
height: 4,
|
||||
data: [
|
||||
0xff0000ff, 0xffffffff, 0x0000ffff, 0xffffffff, 0x000000ff, 0xffffffff,
|
||||
0x000000ff, 0xff000055, 0x00000055, 0x0000ff55, 0x00000055, 0xffffffff,
|
||||
0x000000ff, 0xffffffaa, 0xff0000aa, 0xffffffaa, 0x0000ffaa, 0xffffffff,
|
||||
0x000000ff, 0xffffffff, 0x000000ff, 0xff0000ff, 0x000000ff, 0x0000ffff,
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user