yeet
This commit is contained in:
23
node_modules/@jimp/plugin-contain/CHANGELOG.md
generated
vendored
Normal file
23
node_modules/@jimp/plugin-contain/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-contain/LICENSE
generated
vendored
Normal file
21
node_modules/@jimp/plugin-contain/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.
|
59
node_modules/@jimp/plugin-contain/README.md
generated
vendored
Normal file
59
node_modules/@jimp/plugin-contain/README.md
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
<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-contain</h1>
|
||||
<p>Contain an image within a height and width.</p>
|
||||
</div>
|
||||
|
||||
Scale the image to the given width and height keeping the aspect ratio. Some parts of the image may be letter boxed.
|
||||
|
||||
## Usage
|
||||
|
||||
- @param {number} w the width to resize the image to
|
||||
- @param {number} h the height to resize the image to
|
||||
- @param {number} alignBits (optional) A bitmask for horizontal and vertical alignment
|
||||
- @param {string} mode (optional) a scaling method (e.g. Jimp.RESIZE_BEZIER)
|
||||
- @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.contain(150, 100);
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
### Align modes
|
||||
|
||||
The following constants can be passed to `image.contain`:
|
||||
|
||||
```js
|
||||
Jimp.HORIZONTAL_ALIGN_LEFT;
|
||||
Jimp.HORIZONTAL_ALIGN_CENTER;
|
||||
Jimp.HORIZONTAL_ALIGN_RIGHT;
|
||||
|
||||
Jimp.VERTICAL_ALIGN_TOP;
|
||||
Jimp.VERTICAL_ALIGN_MIDDLE;
|
||||
Jimp.VERTICAL_ALIGN_BOTTOM;
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
image.contain(250, 250, Jimp.HORIZONTAL_ALIGN_LEFT | Jimp.VERTICAL_ALIGN_TOP);
|
||||
image.contain(
|
||||
250,
|
||||
250,
|
||||
Jimp.HORIZONTAL_ALIGN_RIGHT | Jimp.VERTICAL_ALIGN_BOTTOM
|
||||
);
|
||||
```
|
||||
|
||||
Default align mode for `image.contain` is:
|
||||
|
||||
```js
|
||||
Jimp.HORIZONTAL_ALIGN_CENTER | Jimp.VERTICAL_ALIGN_MIDDLE;
|
||||
```
|
75
node_modules/@jimp/plugin-contain/dist/index.js
generated
vendored
Normal file
75
node_modules/@jimp/plugin-contain/dist/index.js
generated
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports["default"] = void 0;
|
||||
|
||||
var _utils = require("@jimp/utils");
|
||||
|
||||
/**
|
||||
* Scale the image to the given width and height keeping the aspect ratio. Some parts of the image may be letter boxed.
|
||||
* @param {number} w the width to resize the image to
|
||||
* @param {number} h the height to resize the image to
|
||||
* @param {number} alignBits (optional) A bitmask for horizontal and vertical alignment
|
||||
* @param {string} mode (optional) a scaling method (e.g. Jimp.RESIZE_BEZIER)
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
var _default = function _default() {
|
||||
return {
|
||||
contain: function contain(w, h, alignBits, mode, cb) {
|
||||
if (typeof w !== 'number' || typeof h !== 'number') {
|
||||
return _utils.throwError.call(this, 'w and h must be numbers', cb);
|
||||
} // permit any sort of optional parameters combination
|
||||
|
||||
|
||||
if (typeof alignBits === 'string') {
|
||||
if (typeof mode === 'function' && typeof cb === 'undefined') cb = mode;
|
||||
mode = alignBits;
|
||||
alignBits = null;
|
||||
}
|
||||
|
||||
if (typeof alignBits === 'function') {
|
||||
if (typeof cb === 'undefined') cb = alignBits;
|
||||
mode = null;
|
||||
alignBits = null;
|
||||
}
|
||||
|
||||
if (typeof mode === 'function' && typeof cb === 'undefined') {
|
||||
cb = mode;
|
||||
mode = null;
|
||||
}
|
||||
|
||||
alignBits = alignBits || this.constructor.HORIZONTAL_ALIGN_CENTER | this.constructor.VERTICAL_ALIGN_MIDDLE;
|
||||
var hbits = alignBits & (1 << 3) - 1;
|
||||
var vbits = alignBits >> 3; // check if more flags than one is in the bit sets
|
||||
|
||||
if (!(hbits !== 0 && !(hbits & hbits - 1) || vbits !== 0 && !(vbits & vbits - 1))) {
|
||||
return _utils.throwError.call(this, 'only use one flag per alignment direction', cb);
|
||||
}
|
||||
|
||||
var alignH = hbits >> 1; // 0, 1, 2
|
||||
|
||||
var alignV = vbits >> 1; // 0, 1, 2
|
||||
|
||||
var f = w / h > this.bitmap.width / this.bitmap.height ? h / this.bitmap.height : w / this.bitmap.width;
|
||||
var c = this.cloneQuiet().scale(f, mode);
|
||||
this.resize(w, h, mode);
|
||||
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {
|
||||
this.bitmap.data.writeUInt32BE(this._background, idx);
|
||||
});
|
||||
this.blit(c, (this.bitmap.width - c.bitmap.width) / 2 * alignH, (this.bitmap.height - c.bitmap.height) / 2 * alignV);
|
||||
|
||||
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-contain/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@jimp/plugin-contain/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
74
node_modules/@jimp/plugin-contain/es/index.js
generated
vendored
Normal file
74
node_modules/@jimp/plugin-contain/es/index.js
generated
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports["default"] = void 0;
|
||||
|
||||
var _utils = require("@jimp/utils");
|
||||
|
||||
/**
|
||||
* Scale the image to the given width and height keeping the aspect ratio. Some parts of the image may be letter boxed.
|
||||
* @param {number} w the width to resize the image to
|
||||
* @param {number} h the height to resize the image to
|
||||
* @param {number} alignBits (optional) A bitmask for horizontal and vertical alignment
|
||||
* @param {string} mode (optional) a scaling method (e.g. Jimp.RESIZE_BEZIER)
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
var _default = function _default() {
|
||||
return {
|
||||
contain: function contain(w, h, alignBits, mode, cb) {
|
||||
if (typeof w !== 'number' || typeof h !== 'number') {
|
||||
return _utils.throwError.call(this, 'w and h must be numbers', cb);
|
||||
} // permit any sort of optional parameters combination
|
||||
|
||||
|
||||
if (typeof alignBits === 'string') {
|
||||
if (typeof mode === 'function' && typeof cb === 'undefined') cb = mode;
|
||||
mode = alignBits;
|
||||
alignBits = null;
|
||||
}
|
||||
|
||||
if (typeof alignBits === 'function') {
|
||||
if (typeof cb === 'undefined') cb = alignBits;
|
||||
mode = null;
|
||||
alignBits = null;
|
||||
}
|
||||
|
||||
if (typeof mode === 'function' && typeof cb === 'undefined') {
|
||||
cb = mode;
|
||||
mode = null;
|
||||
}
|
||||
|
||||
alignBits = alignBits || this.constructor.HORIZONTAL_ALIGN_CENTER | this.constructor.VERTICAL_ALIGN_MIDDLE;
|
||||
var hbits = alignBits & (1 << 3) - 1;
|
||||
var vbits = alignBits >> 3; // check if more flags than one is in the bit sets
|
||||
|
||||
if (!(hbits !== 0 && !(hbits & hbits - 1) || vbits !== 0 && !(vbits & vbits - 1))) {
|
||||
return _utils.throwError.call(this, 'only use one flag per alignment direction', cb);
|
||||
}
|
||||
|
||||
var alignH = hbits >> 1; // 0, 1, 2
|
||||
|
||||
var alignV = vbits >> 1; // 0, 1, 2
|
||||
|
||||
var f = w / h > this.bitmap.width / this.bitmap.height ? h / this.bitmap.height : w / this.bitmap.width;
|
||||
var c = this.cloneQuiet().scale(f, mode);
|
||||
this.resize(w, h, mode);
|
||||
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {
|
||||
this.bitmap.data.writeUInt32BE(this._background, idx);
|
||||
});
|
||||
this.blit(c, (this.bitmap.width - c.bitmap.width) / 2 * alignH, (this.bitmap.height - c.bitmap.height) / 2 * alignV);
|
||||
|
||||
if ((0, _utils.isNodePattern)(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
exports["default"] = _default;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@jimp/plugin-contain/es/index.js.map
generated
vendored
Normal file
1
node_modules/@jimp/plugin-contain/es/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
16
node_modules/@jimp/plugin-contain/index.d.ts
generated
vendored
Normal file
16
node_modules/@jimp/plugin-contain/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
import { ImageCallback } from '@jimp/core';
|
||||
|
||||
interface Contain {
|
||||
contain(w: number, h: number, cb?: ImageCallback<this>): this;
|
||||
contain(w: number, h: number, mode?: string, cb?: ImageCallback<this>): this;
|
||||
contain(w: number, h: number, alignBits?: number, cb?: ImageCallback<this>): this;
|
||||
contain(
|
||||
w: number,
|
||||
h: number,
|
||||
alignBits?: number,
|
||||
mode?: string,
|
||||
cb?: ImageCallback<this>
|
||||
): this;
|
||||
}
|
||||
|
||||
export default function(): Contain;
|
43
node_modules/@jimp/plugin-contain/package.json
generated
vendored
Normal file
43
node_modules/@jimp/plugin-contain/package.json
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "@jimp/plugin-contain",
|
||||
"version": "0.12.1",
|
||||
"description": "contain 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",
|
||||
"@jimp/plugin-blit": ">=0.3.5",
|
||||
"@jimp/plugin-resize": ">=0.3.5",
|
||||
"@jimp/plugin-scale": ">=0.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jimp/custom": "^0.12.1",
|
||||
"@jimp/plugin-blit": "^0.12.1",
|
||||
"@jimp/plugin-resize": "^0.12.1",
|
||||
"@jimp/plugin-scale": "^0.12.1",
|
||||
"@jimp/test-utils": "^0.12.1"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "942e635564e36fc243767531b4f8be036afa40b5"
|
||||
}
|
86
node_modules/@jimp/plugin-contain/src/index.js
generated
vendored
Normal file
86
node_modules/@jimp/plugin-contain/src/index.js
generated
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
import { isNodePattern, throwError } from '@jimp/utils';
|
||||
|
||||
/**
|
||||
* Scale the image to the given width and height keeping the aspect ratio. Some parts of the image may be letter boxed.
|
||||
* @param {number} w the width to resize the image to
|
||||
* @param {number} h the height to resize the image to
|
||||
* @param {number} alignBits (optional) A bitmask for horizontal and vertical alignment
|
||||
* @param {string} mode (optional) a scaling method (e.g. Jimp.RESIZE_BEZIER)
|
||||
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
|
||||
* @returns {Jimp} this for chaining of methods
|
||||
*/
|
||||
export default () => ({
|
||||
contain(w, h, alignBits, mode, cb) {
|
||||
if (typeof w !== 'number' || typeof h !== 'number') {
|
||||
return throwError.call(this, 'w and h must be numbers', cb);
|
||||
}
|
||||
|
||||
// permit any sort of optional parameters combination
|
||||
if (typeof alignBits === 'string') {
|
||||
if (typeof mode === 'function' && typeof cb === 'undefined') cb = mode;
|
||||
mode = alignBits;
|
||||
alignBits = null;
|
||||
}
|
||||
|
||||
if (typeof alignBits === 'function') {
|
||||
if (typeof cb === 'undefined') cb = alignBits;
|
||||
mode = null;
|
||||
alignBits = null;
|
||||
}
|
||||
|
||||
if (typeof mode === 'function' && typeof cb === 'undefined') {
|
||||
cb = mode;
|
||||
mode = null;
|
||||
}
|
||||
|
||||
alignBits =
|
||||
alignBits ||
|
||||
this.constructor.HORIZONTAL_ALIGN_CENTER |
|
||||
this.constructor.VERTICAL_ALIGN_MIDDLE;
|
||||
const hbits = alignBits & ((1 << 3) - 1);
|
||||
const vbits = alignBits >> 3;
|
||||
|
||||
// check if more flags than one is in the bit sets
|
||||
if (
|
||||
!(
|
||||
(hbits !== 0 && !(hbits & (hbits - 1))) ||
|
||||
(vbits !== 0 && !(vbits & (vbits - 1)))
|
||||
)
|
||||
) {
|
||||
return throwError.call(
|
||||
this,
|
||||
'only use one flag per alignment direction',
|
||||
cb
|
||||
);
|
||||
}
|
||||
|
||||
const alignH = hbits >> 1; // 0, 1, 2
|
||||
const alignV = vbits >> 1; // 0, 1, 2
|
||||
|
||||
const f =
|
||||
w / h > this.bitmap.width / this.bitmap.height
|
||||
? h / this.bitmap.height
|
||||
: w / this.bitmap.width;
|
||||
const c = this.cloneQuiet().scale(f, mode);
|
||||
|
||||
this.resize(w, h, mode);
|
||||
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function(
|
||||
x,
|
||||
y,
|
||||
idx
|
||||
) {
|
||||
this.bitmap.data.writeUInt32BE(this._background, idx);
|
||||
});
|
||||
this.blit(
|
||||
c,
|
||||
((this.bitmap.width - c.bitmap.width) / 2) * alignH,
|
||||
((this.bitmap.height - c.bitmap.height) / 2) * alignV
|
||||
);
|
||||
|
||||
if (isNodePattern(cb)) {
|
||||
cb.call(this, null, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
131
node_modules/@jimp/plugin-contain/test/contain.test.js
generated
vendored
Normal file
131
node_modules/@jimp/plugin-contain/test/contain.test.js
generated
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
import { Jimp, mkJGD, hasOwnProp } from '@jimp/test-utils';
|
||||
import configure from '@jimp/custom';
|
||||
import blit from '@jimp/plugin-blit';
|
||||
import resize from '@jimp/plugin-resize';
|
||||
import scale from '@jimp/plugin-scale';
|
||||
|
||||
import contain from '../src';
|
||||
|
||||
const jimp = configure({ plugins: [scale, resize, blit, contain] }, Jimp);
|
||||
|
||||
describe('All align combinations for contain', () => {
|
||||
const verticalJGD = mkJGD(
|
||||
'▴▴▴▴▸▸▸▸',
|
||||
'▴▴▴▴▸▸▸▸',
|
||||
'▴▴▴▴▸▸▸▸',
|
||||
'▴▴▴▴▸▸▸▸',
|
||||
'▴▴▴▴▸▸▸▸',
|
||||
'▴▴▴▴▸▸▸▸',
|
||||
'▾▾▾▾◆◆◆◆',
|
||||
'▾▾▾▾◆◆◆◆',
|
||||
'▾▾▾▾◆◆◆◆',
|
||||
'▾▾▾▾◆◆◆◆',
|
||||
'▾▾▾▾◆◆◆◆',
|
||||
'▾▾▾▾◆◆◆◆'
|
||||
);
|
||||
|
||||
const horizontalJGD = mkJGD(
|
||||
'▴▴▴▴▴▴▸▸▸▸▸▸',
|
||||
'▴▴▴▴▴▴▸▸▸▸▸▸',
|
||||
'▴▴▴▴▴▴▸▸▸▸▸▸',
|
||||
'▴▴▴▴▴▴▸▸▸▸▸▸',
|
||||
'▾▾▾▾▾▾◆◆◆◆◆◆',
|
||||
'▾▾▾▾▾▾◆◆◆◆◆◆',
|
||||
'▾▾▾▾▾▾◆◆◆◆◆◆',
|
||||
'▾▾▾▾▾▾◆◆◆◆◆◆'
|
||||
);
|
||||
|
||||
let vertical;
|
||||
let horizontal; // stores the Jimp instances of the JGD images above.
|
||||
|
||||
before(done => {
|
||||
const img1 = jimp.read(verticalJGD);
|
||||
const img2 = jimp.read(horizontalJGD);
|
||||
Promise.all([img1, img2])
|
||||
.then(images => {
|
||||
vertical = images[0];
|
||||
horizontal = images[1];
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
const tests = {}; // Stores the expected result for each alignment combination.
|
||||
tests['LEFT TOP'] = {
|
||||
contain: {
|
||||
verti: mkJGD('▴▴▸▸ ', '▴▴▸▸ ', '▴▴▸▸ ', '▾▾◆◆ ', '▾▾◆◆ ', '▾▾◆◆ '),
|
||||
horiz: mkJGD('▴▴▴▸▸▸', '▴▴▴▸▸▸', '▾▾▾◆◆◆', '▾▾▾◆◆◆', ' ', ' ')
|
||||
}
|
||||
};
|
||||
tests['CENTER TOP'] = {
|
||||
contain: {
|
||||
verti: mkJGD(' ▴▴▸▸ ', ' ▴▴▸▸ ', ' ▴▴▸▸ ', ' ▾▾◆◆ ', ' ▾▾◆◆ ', ' ▾▾◆◆ '),
|
||||
horiz: mkJGD('▴▴▴▸▸▸', '▴▴▴▸▸▸', '▾▾▾◆◆◆', '▾▾▾◆◆◆', ' ', ' ')
|
||||
}
|
||||
};
|
||||
tests['RIGHT TOP'] = {
|
||||
contain: {
|
||||
verti: mkJGD(' ▴▴▸▸', ' ▴▴▸▸', ' ▴▴▸▸', ' ▾▾◆◆', ' ▾▾◆◆', ' ▾▾◆◆'),
|
||||
horiz: mkJGD('▴▴▴▸▸▸', '▴▴▴▸▸▸', '▾▾▾◆◆◆', '▾▾▾◆◆◆', ' ', ' ')
|
||||
}
|
||||
};
|
||||
|
||||
tests['LEFT MIDDLE'] = {
|
||||
contain: {
|
||||
verti: mkJGD('▴▴▸▸ ', '▴▴▸▸ ', '▴▴▸▸ ', '▾▾◆◆ ', '▾▾◆◆ ', '▾▾◆◆ '),
|
||||
horiz: mkJGD(' ', '▴▴▴▸▸▸', '▴▴▴▸▸▸', '▾▾▾◆◆◆', '▾▾▾◆◆◆', ' ')
|
||||
}
|
||||
};
|
||||
tests['CENTER MIDDLE'] = {
|
||||
contain: {
|
||||
verti: mkJGD(' ▴▴▸▸ ', ' ▴▴▸▸ ', ' ▴▴▸▸ ', ' ▾▾◆◆ ', ' ▾▾◆◆ ', ' ▾▾◆◆ '),
|
||||
horiz: mkJGD(' ', '▴▴▴▸▸▸', '▴▴▴▸▸▸', '▾▾▾◆◆◆', '▾▾▾◆◆◆', ' ')
|
||||
}
|
||||
};
|
||||
tests['RIGHT MIDDLE'] = {
|
||||
contain: {
|
||||
verti: mkJGD(' ▴▴▸▸', ' ▴▴▸▸', ' ▴▴▸▸', ' ▾▾◆◆', ' ▾▾◆◆', ' ▾▾◆◆'),
|
||||
horiz: mkJGD(' ', '▴▴▴▸▸▸', '▴▴▴▸▸▸', '▾▾▾◆◆◆', '▾▾▾◆◆◆', ' ')
|
||||
}
|
||||
};
|
||||
|
||||
tests['LEFT BOTTOM'] = {
|
||||
contain: {
|
||||
verti: mkJGD('▴▴▸▸ ', '▴▴▸▸ ', '▴▴▸▸ ', '▾▾◆◆ ', '▾▾◆◆ ', '▾▾◆◆ '),
|
||||
horiz: mkJGD(' ', ' ', '▴▴▴▸▸▸', '▴▴▴▸▸▸', '▾▾▾◆◆◆', '▾▾▾◆◆◆')
|
||||
}
|
||||
};
|
||||
tests['CENTER BOTTOM'] = {
|
||||
contain: {
|
||||
verti: mkJGD(' ▴▴▸▸ ', ' ▴▴▸▸ ', ' ▴▴▸▸ ', ' ▾▾◆◆ ', ' ▾▾◆◆ ', ' ▾▾◆◆ '),
|
||||
horiz: mkJGD(' ', ' ', '▴▴▴▸▸▸', '▴▴▴▸▸▸', '▾▾▾◆◆◆', '▾▾▾◆◆◆')
|
||||
}
|
||||
};
|
||||
tests['RIGHT BOTTOM'] = {
|
||||
contain: {
|
||||
verti: mkJGD(' ▴▴▸▸', ' ▴▴▸▸', ' ▴▴▸▸', ' ▾▾◆◆', ' ▾▾◆◆', ' ▾▾◆◆'),
|
||||
horiz: mkJGD(' ', ' ', '▴▴▴▸▸▸', '▴▴▴▸▸▸', '▾▾▾◆◆◆', '▾▾▾◆◆◆')
|
||||
}
|
||||
};
|
||||
|
||||
function runAlignTest(align) {
|
||||
const jgdContainV = tests[align].contain.verti;
|
||||
const jgdContainH = tests[align].contain.horiz;
|
||||
let a = align.split(' ');
|
||||
a = Jimp['HORIZONTAL_ALIGN_' + a[0]] | Jimp['VERTICAL_ALIGN_' + a[1]];
|
||||
it('contain aligned to ' + align, () => {
|
||||
vertical
|
||||
.clone()
|
||||
.contain(6, 6, a)
|
||||
.getJGDSync()
|
||||
.should.be.sameJGD(jgdContainV, 'Vertical image');
|
||||
horizontal
|
||||
.clone()
|
||||
.contain(6, 6, a)
|
||||
.getJGDSync()
|
||||
.should.be.sameJGD(jgdContainH, 'Horizontal image');
|
||||
});
|
||||
}
|
||||
|
||||
for (const align in tests) if (hasOwnProp(tests, align)) runAlignTest(align);
|
||||
});
|
Reference in New Issue
Block a user