Add: node_modules
This commit is contained in:
21
app/node_modules/@jimp/plugin-mask/LICENSE
generated
vendored
Normal file
21
app/node_modules/@jimp/plugin-mask/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.
|
26
app/node_modules/@jimp/plugin-mask/README.md
generated
vendored
Normal file
26
app/node_modules/@jimp/plugin-mask/README.md
generated
vendored
Normal file
@@ -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);
|
||||
}
|
||||
```
|
64
app/node_modules/@jimp/plugin-mask/dist/index.js
generated
vendored
Normal file
64
app/node_modules/@jimp/plugin-mask/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
|
||||
require("core-js/modules/es6.object.define-property");
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _utils = require("@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
|
||||
*/
|
||||
var _default = function _default() {
|
||||
return {
|
||||
mask: function mask(src) {
|
||||
var x = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
||||
var y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
||||
var cb = arguments.length > 3 ? arguments[3] : undefined;
|
||||
|
||||
if (!(src instanceof this.constructor)) {
|
||||
return _utils.throwError.call(this, 'The source must be a Jimp image', cb);
|
||||
}
|
||||
|
||||
if (typeof x !== 'number' || typeof y !== 'number') {
|
||||
return _utils.throwError.call(this, 'x and y must be numbers', cb);
|
||||
} // round input
|
||||
|
||||
|
||||
x = Math.round(x);
|
||||
y = Math.round(y);
|
||||
var w = this.bitmap.width;
|
||||
var h = this.bitmap.height;
|
||||
var baseImage = this;
|
||||
src.scanQuiet(0, 0, src.bitmap.width, src.bitmap.height, function (sx, sy, idx) {
|
||||
var destX = x + sx;
|
||||
var destY = y + sy;
|
||||
|
||||
if (destX >= 0 && destY >= 0 && destX < w && destY < h) {
|
||||
var dstIdx = baseImage.getPixelIndex(destX, destY);
|
||||
var data = this.bitmap.data;
|
||||
var avg = (data[idx + 0] + data[idx + 1] + data[idx + 2]) / 3;
|
||||
baseImage.bitmap.data[dstIdx + 3] *= avg / 255;
|
||||
}
|
||||
});
|
||||
|
||||
if ((0, _utils.isNodePattern)(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
exports.default = _default;
|
||||
module.exports = exports.default;
|
||||
//# sourceMappingURL=index.js.map
|
1
app/node_modules/@jimp/plugin-mask/dist/index.js.map
generated
vendored
Normal file
1
app/node_modules/@jimp/plugin-mask/dist/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../src/index.js"],"names":["mask","src","x","y","cb","constructor","throwError","call","Math","round","w","bitmap","width","h","height","baseImage","scanQuiet","sx","sy","idx","destX","destY","dstIdx","getPixelIndex","data","avg"],"mappings":";;;;;;;;;AAAA;;AAEA;;;;;;;;eAQe;AAAA,SAAO;AACpBA,IAAAA,IADoB,gBACfC,GADe,EACQ;AAAA,UAAlBC,CAAkB,uEAAd,CAAc;AAAA,UAAXC,CAAW,uEAAP,CAAO;AAAA,UAAJC,EAAI;;AAC1B,UAAI,EAAEH,GAAG,YAAY,KAAKI,WAAtB,CAAJ,EAAwC;AACtC,eAAOC,kBAAWC,IAAX,CAAgB,IAAhB,EAAsB,iCAAtB,EAAyDH,EAAzD,CAAP;AACD;;AAED,UAAI,OAAOF,CAAP,KAAa,QAAb,IAAyB,OAAOC,CAAP,KAAa,QAA1C,EAAoD;AAClD,eAAOG,kBAAWC,IAAX,CAAgB,IAA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BA,QAAAA,EAAE,CAACG,IAAH,CAAQ,IAAR,EAAc,IAAd,EAAoB,IAApB;AACD;;AAED,aAAO,IAAP;AACD;AAxCmB,GAAP;AAAA,C","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(0, 0, src.bitmap.width, src.bitmap.height, function(\n sx,\n sy,\n idx\n ) {\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 if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n }\n});\n"],"file":"index.js"}
|
52
app/node_modules/@jimp/plugin-mask/es/index.js
generated
vendored
Normal file
52
app/node_modules/@jimp/plugin-mask/es/index.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
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 (function () {
|
||||
return {
|
||||
mask: function mask(src) {
|
||||
var x = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
||||
var y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
||||
var 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);
|
||||
var w = this.bitmap.width;
|
||||
var h = this.bitmap.height;
|
||||
var baseImage = this;
|
||||
src.scanQuiet(0, 0, src.bitmap.width, src.bitmap.height, function (sx, sy, idx) {
|
||||
var destX = x + sx;
|
||||
var destY = y + sy;
|
||||
|
||||
if (destX >= 0 && destY >= 0 && destX < w && destY < h) {
|
||||
var dstIdx = baseImage.getPixelIndex(destX, destY);
|
||||
var data = this.bitmap.data;
|
||||
var 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
app/node_modules/@jimp/plugin-mask/es/index.js.map
generated
vendored
Normal file
1
app/node_modules/@jimp/plugin-mask/es/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../src/index.js"],"names":["isNodePattern","throwError","mask","src","x","y","cb","constructor","call","Math","round","w","bitmap","width","h","height","baseImage","scanQ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KAAK,GAAGV,CAApC,IAAyCW,KAAK,GAAGR,CAArD,EAAwD;AACtD,cAAMS,MAAM,GAAGP,SAAS,CAACQ,aAAV,CAAwBH,KAAxB,EAA+BC,KAA/B,CAAf;AADsD,cAE9CG,IAF8C,GAErC,KAAKb,MAFgC,CAE9Ca,IAF8C;AAGtD,cAAMC,GAAG,GAAG,CAACD,IAAI,CAACL,GAAG,GAAG,CAAP,CAAJ,GAAgBK,IAAI,CAACL,GAAG,GAAG,CAAP,CAApB,GAAgCK,IAAI,CAACL,GAAG,GAAG,CAAP,CAArC,IAAkD,CAA9D;AAEAJ,UAAAA,SAAS,CAACJ,MAAV,CAAiBa,IAAjB,CAAsBF,MAAM,GAAG,CAA/B,KAAqCG,GAAG,GAAG,GAA3C;AACD;AACF,OAfD;;AAiBA,UAAI1B,aAAa,CAACM,EAAD,CAAjB,EAAuB;AACrBA,QAAAA,EAAE,CAACE,IAAH,CAAQ,IAAR,EAAc,IAAd,EAAoB,IAApB;AACD;;AAED,aAAO,IAAP;AACD;AAxCmB,GAAP;AAAA,CAAf","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(0, 0, src.bitmap.width, src.bitmap.height, function(\n sx,\n sy,\n idx\n ) {\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 if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n }\n});\n"],"file":"index.js"}
|
65
app/node_modules/@jimp/plugin-mask/package.json
generated
vendored
Normal file
65
app/node_modules/@jimp/plugin-mask/package.json
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"@jimp/plugin-mask@0.6.4",
|
||||
"C:\\Users\\ryuki\\TheDesk\\app"
|
||||
]
|
||||
],
|
||||
"_from": "@jimp/plugin-mask@0.6.4",
|
||||
"_id": "@jimp/plugin-mask@0.6.4",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-3D4FbRxnpO9nzwa6cF8AImgO1aVReYbfRRO4I4bku4/iZ+kuU3fBLV+SRhB4c7di3ejG5u+rGsIfaNc94iYYvw==",
|
||||
"_location": "/@jimp/plugin-mask",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "@jimp/plugin-mask@0.6.4",
|
||||
"name": "@jimp/plugin-mask",
|
||||
"escapedName": "@jimp%2fplugin-mask",
|
||||
"scope": "@jimp",
|
||||
"rawSpec": "0.6.4",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "0.6.4"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@jimp/plugins"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@jimp/plugin-mask/-/plugin-mask-0.6.4.tgz",
|
||||
"_spec": "0.6.4",
|
||||
"_where": "C:\\Users\\ryuki\\TheDesk\\app",
|
||||
"author": "",
|
||||
"dependencies": {
|
||||
"@jimp/utils": "^0.6.4",
|
||||
"core-js": "^2.5.7"
|
||||
},
|
||||
"description": "mask an image.",
|
||||
"devDependencies": {
|
||||
"@jimp/custom": "^0.6.4",
|
||||
"@jimp/test-utils": "^0.6.4"
|
||||
},
|
||||
"gitHead": "7c9d3c817cade88d4a20422be10670d3c1528429",
|
||||
"license": "MIT",
|
||||
"main": "dist/index.js",
|
||||
"module": "es/index.js",
|
||||
"name": "@jimp/plugin-mask",
|
||||
"peerDependencies": {
|
||||
"@jimp/custom": ">=0.3.5"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run build:node:production && npm run build:module",
|
||||
"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",
|
||||
"build:watch": "npm run build:node:debug -- -- --watch --verbose",
|
||||
"test": "cross-env BABEL_ENV=test mocha --require @babel/register",
|
||||
"test:coverage": "nyc npm run test",
|
||||
"test:watch": "npm run test -- --reporter min --watch"
|
||||
},
|
||||
"version": "0.6.4"
|
||||
}
|
52
app/node_modules/@jimp/plugin-mask/src/index.js
generated
vendored
Normal file
52
app/node_modules/@jimp/plugin-mask/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
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;
|
||||
}
|
||||
});
|
305
app/node_modules/@jimp/plugin-mask/test/mask.test.js
generated
vendored
Normal file
305
app/node_modules/@jimp/plugin-mask/test/mask.test.js
generated
vendored
Normal file
@@ -0,0 +1,305 @@
|
||||
import { Jimp, mkJGD } from '@jimp/test-utils';
|
||||
import configure from '@jimp/custom';
|
||||
|
||||
import mask from '../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', () => {
|
||||
imgSrcOpaq
|
||||
.clone()
|
||||
.mask(maskGrayBig)
|
||||
.getJGDSync()
|
||||
.should.be.sameJGD({
|
||||
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', () => {
|
||||
imgSrcOpaq
|
||||
.clone()
|
||||
.mask(maskGrayBig, 1, 1)
|
||||
.getJGDSync()
|
||||
.should.be.sameJGD({
|
||||
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', () => {
|
||||
imgSrcOpaq
|
||||
.clone()
|
||||
.mask(maskGrayBig, -1, -1)
|
||||
.getJGDSync()
|
||||
.should.be.sameJGD({
|
||||
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', () => {
|
||||
imgSrcOpaq
|
||||
.clone()
|
||||
.mask(maskGraySmall)
|
||||
.getJGDSync()
|
||||
.should.be.sameJGD({
|
||||
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', () => {
|
||||
imgSrcOpaq
|
||||
.clone()
|
||||
.mask(maskGraySmall, 1, 1)
|
||||
.getJGDSync()
|
||||
.should.be.sameJGD({
|
||||
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', () => {
|
||||
imgSrcAlpa
|
||||
.clone()
|
||||
.mask(maskGrayBig)
|
||||
.getJGDSync()
|
||||
.should.be.sameJGD({
|
||||
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', () => {
|
||||
imgSrcAlpa
|
||||
.clone()
|
||||
.mask(maskGrayBig, -1, -1)
|
||||
.getJGDSync()
|
||||
.should.be.sameJGD({
|
||||
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', () => {
|
||||
imgSrcOpaq
|
||||
.clone()
|
||||
.mask(maskColor, 1, 1)
|
||||
.getJGDSync()
|
||||
.should.be.sameJGD({
|
||||
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