Add: node_modules

This commit is contained in:
Cutls
2019-09-12 23:38:13 +09:00
parent 4769c83958
commit 25a1db84a4
7934 changed files with 956263 additions and 1 deletions

21
app/node_modules/@jimp/plugin-rotate/LICENSE generated vendored Normal file
View 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-rotate/README.md generated vendored Normal file
View 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-rotate</h1>
<p>Rotate an image.</p>
</div>
Rotates the image clockwise by a number of degrees. By default the width and height of the image will be resized appropriately.
## Usage
- @param {number} deg the number of degrees to rotate the image by
- @param {string|boolean} mode (optional) resize mode or a boolean, if false then the width and height of the image will not be changed
- @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.rotate(90);
}
main();
```

160
app/node_modules/@jimp/plugin-rotate/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,160 @@
"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");
function rotate90degrees(bitmap, dstBuffer, clockwise) {
var dstOffsetStep = clockwise ? -4 : 4;
var dstOffset = clockwise ? dstBuffer.length - 4 : 0;
var tmp;
var x;
var y;
var srcOffset;
for (x = 0; x < bitmap.width; x++) {
for (y = bitmap.height - 1; y >= 0; y--) {
srcOffset = bitmap.width * y + x << 2;
tmp = bitmap.data.readUInt32BE(srcOffset, true);
dstBuffer.writeUInt32BE(tmp, dstOffset, true);
dstOffset += dstOffsetStep;
}
}
}
/**
* Rotates an image clockwise by an arbitrary number of degrees. NB: 'this' must be a Jimp object.
* @param {number} deg the number of degrees to rotate the image by
* @param {string|boolean} mode (optional) resize mode or a boolean, if false then the width and height of the image will not be changed
*/
function advancedRotate(deg, mode) {
deg %= 360;
var rad = deg * Math.PI / 180;
var cosine = Math.cos(rad);
var sine = Math.sin(rad); // the final width and height will change if resize == true
var w = this.bitmap.width;
var h = this.bitmap.height;
if (mode === true || typeof mode === 'string') {
// resize the image to it maximum dimension and blit the existing image
// onto the center so that when it is rotated the image is kept in bounds
// http://stackoverflow.com/questions/3231176/how-to-get-size-of-a-rotated-rectangle
// Plus 1 border pixel to ensure to show all rotated result for some cases.
w = Math.ceil(Math.abs(this.bitmap.width * cosine) + Math.abs(this.bitmap.height * sine)) + 1;
h = Math.ceil(Math.abs(this.bitmap.width * sine) + Math.abs(this.bitmap.height * cosine)) + 1; // Ensure destination to have even size to a better result.
if (w % 2 !== 0) {
w++;
}
if (h % 2 !== 0) {
h++;
}
var c = this.cloneQuiet();
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {
this.bitmap.data.writeUInt32BE(this._background, idx);
});
var max = Math.max(w, h, this.bitmap.width, this.bitmap.height);
this.resize(max, max, mode);
this.blit(c, this.bitmap.width / 2 - c.bitmap.width / 2, this.bitmap.height / 2 - c.bitmap.height / 2);
}
var bW = this.bitmap.width;
var bH = this.bitmap.height;
var dstBuffer = Buffer.alloc(this.bitmap.data.length);
function createTranslationFunction(deltaX, deltaY) {
return function (x, y) {
return {
x: x + deltaX,
y: y + deltaY
};
};
}
var translate2Cartesian = createTranslationFunction(-(bW / 2), -(bH / 2));
var translate2Screen = createTranslationFunction(bW / 2 + 0.5, bH / 2 + 0.5);
for (var y = 1; y <= bH; y++) {
for (var x = 1; x <= bW; x++) {
var cartesian = translate2Cartesian(x, y);
var source = translate2Screen(cosine * cartesian.x - sine * cartesian.y, cosine * cartesian.y + sine * cartesian.x);
var dstIdx = bW * (y - 1) + x - 1 << 2;
if (source.x >= 0 && source.x < bW && source.y >= 0 && source.y < bH) {
var srcIdx = (bW * (source.y | 0) + source.x | 0) << 2;
var pixelRGBA = this.bitmap.data.readUInt32BE(srcIdx);
dstBuffer.writeUInt32BE(pixelRGBA, dstIdx);
} else {
// reset off-image pixels
dstBuffer.writeUInt32BE(this._background, dstIdx);
}
}
}
this.bitmap.data = dstBuffer;
if (mode === true || typeof mode === 'string') {
// now crop the image to the final size
var _x = bW / 2 - w / 2;
var _y = bH / 2 - h / 2;
this.crop(_x, _y, w, h);
}
}
var _default = function _default() {
return {
/**
* Rotates the image clockwise by a number of degrees. By default the width and height of the image will be resized appropriately.
* @param {number} deg the number of degrees to rotate the image by
* @param {string|boolean} mode (optional) resize mode or a boolean, if false then the width and height of the image will not be changed
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
* @returns {Jimp} this for chaining of methods
*/
rotate: function rotate(deg, mode, cb) {
// enable overloading
if (typeof mode === 'undefined' || mode === null) {
// e.g. image.resize(120);
// e.g. image.resize(120, null, cb);
// e.g. image.resize(120, undefined, cb);
mode = true;
}
if (typeof mode === 'function' && typeof cb === 'undefined') {
// e.g. image.resize(120, cb);
cb = mode;
mode = true;
}
if (typeof deg !== 'number') {
return _utils.throwError.call(this, 'deg must be a number', cb);
}
if (typeof mode !== 'boolean' && typeof mode !== 'string') {
return _utils.throwError.call(this, 'mode must be a boolean or a string', cb);
}
advancedRotate.call(this, deg, mode, cb);
if ((0, _utils.isNodePattern)(cb)) {
cb.call(this, null, this);
}
return this;
}
};
};
exports.default = _default;
module.exports = exports.default;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

148
app/node_modules/@jimp/plugin-rotate/es/index.js generated vendored Normal file
View File

@@ -0,0 +1,148 @@
import { throwError, isNodePattern } from '@jimp/utils';
function rotate90degrees(bitmap, dstBuffer, clockwise) {
var dstOffsetStep = clockwise ? -4 : 4;
var dstOffset = clockwise ? dstBuffer.length - 4 : 0;
var tmp;
var x;
var y;
var srcOffset;
for (x = 0; x < bitmap.width; x++) {
for (y = bitmap.height - 1; y >= 0; y--) {
srcOffset = bitmap.width * y + x << 2;
tmp = bitmap.data.readUInt32BE(srcOffset, true);
dstBuffer.writeUInt32BE(tmp, dstOffset, true);
dstOffset += dstOffsetStep;
}
}
}
/**
* Rotates an image clockwise by an arbitrary number of degrees. NB: 'this' must be a Jimp object.
* @param {number} deg the number of degrees to rotate the image by
* @param {string|boolean} mode (optional) resize mode or a boolean, if false then the width and height of the image will not be changed
*/
function advancedRotate(deg, mode) {
deg %= 360;
var rad = deg * Math.PI / 180;
var cosine = Math.cos(rad);
var sine = Math.sin(rad); // the final width and height will change if resize == true
var w = this.bitmap.width;
var h = this.bitmap.height;
if (mode === true || typeof mode === 'string') {
// resize the image to it maximum dimension and blit the existing image
// onto the center so that when it is rotated the image is kept in bounds
// http://stackoverflow.com/questions/3231176/how-to-get-size-of-a-rotated-rectangle
// Plus 1 border pixel to ensure to show all rotated result for some cases.
w = Math.ceil(Math.abs(this.bitmap.width * cosine) + Math.abs(this.bitmap.height * sine)) + 1;
h = Math.ceil(Math.abs(this.bitmap.width * sine) + Math.abs(this.bitmap.height * cosine)) + 1; // Ensure destination to have even size to a better result.
if (w % 2 !== 0) {
w++;
}
if (h % 2 !== 0) {
h++;
}
var c = this.cloneQuiet();
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {
this.bitmap.data.writeUInt32BE(this._background, idx);
});
var max = Math.max(w, h, this.bitmap.width, this.bitmap.height);
this.resize(max, max, mode);
this.blit(c, this.bitmap.width / 2 - c.bitmap.width / 2, this.bitmap.height / 2 - c.bitmap.height / 2);
}
var bW = this.bitmap.width;
var bH = this.bitmap.height;
var dstBuffer = Buffer.alloc(this.bitmap.data.length);
function createTranslationFunction(deltaX, deltaY) {
return function (x, y) {
return {
x: x + deltaX,
y: y + deltaY
};
};
}
var translate2Cartesian = createTranslationFunction(-(bW / 2), -(bH / 2));
var translate2Screen = createTranslationFunction(bW / 2 + 0.5, bH / 2 + 0.5);
for (var y = 1; y <= bH; y++) {
for (var x = 1; x <= bW; x++) {
var cartesian = translate2Cartesian(x, y);
var source = translate2Screen(cosine * cartesian.x - sine * cartesian.y, cosine * cartesian.y + sine * cartesian.x);
var dstIdx = bW * (y - 1) + x - 1 << 2;
if (source.x >= 0 && source.x < bW && source.y >= 0 && source.y < bH) {
var srcIdx = (bW * (source.y | 0) + source.x | 0) << 2;
var pixelRGBA = this.bitmap.data.readUInt32BE(srcIdx);
dstBuffer.writeUInt32BE(pixelRGBA, dstIdx);
} else {
// reset off-image pixels
dstBuffer.writeUInt32BE(this._background, dstIdx);
}
}
}
this.bitmap.data = dstBuffer;
if (mode === true || typeof mode === 'string') {
// now crop the image to the final size
var _x = bW / 2 - w / 2;
var _y = bH / 2 - h / 2;
this.crop(_x, _y, w, h);
}
}
export default (function () {
return {
/**
* Rotates the image clockwise by a number of degrees. By default the width and height of the image will be resized appropriately.
* @param {number} deg the number of degrees to rotate the image by
* @param {string|boolean} mode (optional) resize mode or a boolean, if false then the width and height of the image will not be changed
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
* @returns {Jimp} this for chaining of methods
*/
rotate: function rotate(deg, mode, cb) {
// enable overloading
if (typeof mode === 'undefined' || mode === null) {
// e.g. image.resize(120);
// e.g. image.resize(120, null, cb);
// e.g. image.resize(120, undefined, cb);
mode = true;
}
if (typeof mode === 'function' && typeof cb === 'undefined') {
// e.g. image.resize(120, cb);
cb = mode;
mode = true;
}
if (typeof deg !== 'number') {
return throwError.call(this, 'deg must be a number', cb);
}
if (typeof mode !== 'boolean' && typeof mode !== 'string') {
return throwError.call(this, 'mode must be a boolean or a string', cb);
}
advancedRotate.call(this, deg, mode, cb);
if (isNodePattern(cb)) {
cb.call(this, null, this);
}
return this;
}
};
});
//# sourceMappingURL=index.js.map

1
app/node_modules/@jimp/plugin-rotate/es/index.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

71
app/node_modules/@jimp/plugin-rotate/package.json generated vendored Normal file
View File

@@ -0,0 +1,71 @@
{
"_args": [
[
"@jimp/plugin-rotate@0.6.4",
"C:\\Users\\ryuki\\TheDesk\\app"
]
],
"_from": "@jimp/plugin-rotate@0.6.4",
"_id": "@jimp/plugin-rotate@0.6.4",
"_inBundle": false,
"_integrity": "sha512-44VgV5D4xQIYInJAVevdW9J3SOhGKyz0OEr2ciA8Q3ktonKx0O5Q1g2kbruiqxFSkK/u2CKPLeKXZzYCFrmJGQ==",
"_location": "/@jimp/plugin-rotate",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@jimp/plugin-rotate@0.6.4",
"name": "@jimp/plugin-rotate",
"escapedName": "@jimp%2fplugin-rotate",
"scope": "@jimp",
"rawSpec": "0.6.4",
"saveSpec": null,
"fetchSpec": "0.6.4"
},
"_requiredBy": [
"/@jimp/plugins"
],
"_resolved": "https://registry.npmjs.org/@jimp/plugin-rotate/-/plugin-rotate-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": "Rotate an image.",
"devDependencies": {
"@jimp/custom": "^0.6.4",
"@jimp/plugin-blit": "^0.6.4",
"@jimp/plugin-crop": "^0.6.4",
"@jimp/plugin-resize": "^0.6.4",
"@jimp/test-utils": "^0.6.4"
},
"gitHead": "7c9d3c817cade88d4a20422be10670d3c1528429",
"license": "MIT",
"main": "dist/index.js",
"module": "es/index.js",
"name": "@jimp/plugin-rotate",
"peerDependencies": {
"@jimp/custom": ">=0.3.5",
"@jimp/plugin-blit": ">=0.3.5",
"@jimp/plugin-crop": ">=0.3.5",
"@jimp/plugin-resize": ">=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"
}

168
app/node_modules/@jimp/plugin-rotate/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,168 @@
import { throwError, isNodePattern } from '@jimp/utils';
function rotate90degrees(bitmap, dstBuffer, clockwise) {
const dstOffsetStep = clockwise ? -4 : 4;
let dstOffset = clockwise ? dstBuffer.length - 4 : 0;
let tmp;
let x;
let y;
let srcOffset;
for (x = 0; x < bitmap.width; x++) {
for (y = bitmap.height - 1; y >= 0; y--) {
srcOffset = (bitmap.width * y + x) << 2;
tmp = bitmap.data.readUInt32BE(srcOffset, true);
dstBuffer.writeUInt32BE(tmp, dstOffset, true);
dstOffset += dstOffsetStep;
}
}
}
/**
* Rotates an image clockwise by an arbitrary number of degrees. NB: 'this' must be a Jimp object.
* @param {number} deg the number of degrees to rotate the image by
* @param {string|boolean} mode (optional) resize mode or a boolean, if false then the width and height of the image will not be changed
*/
function advancedRotate(deg, mode) {
deg %= 360;
const rad = (deg * Math.PI) / 180;
const cosine = Math.cos(rad);
const sine = Math.sin(rad);
// the final width and height will change if resize == true
let w = this.bitmap.width;
let h = this.bitmap.height;
if (mode === true || typeof mode === 'string') {
// resize the image to it maximum dimension and blit the existing image
// onto the center so that when it is rotated the image is kept in bounds
// http://stackoverflow.com/questions/3231176/how-to-get-size-of-a-rotated-rectangle
// Plus 1 border pixel to ensure to show all rotated result for some cases.
w =
Math.ceil(
Math.abs(this.bitmap.width * cosine) +
Math.abs(this.bitmap.height * sine)
) + 1;
h =
Math.ceil(
Math.abs(this.bitmap.width * sine) +
Math.abs(this.bitmap.height * cosine)
) + 1;
// Ensure destination to have even size to a better result.
if (w % 2 !== 0) {
w++;
}
if (h % 2 !== 0) {
h++;
}
const c = this.cloneQuiet();
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function(
x,
y,
idx
) {
this.bitmap.data.writeUInt32BE(this._background, idx);
});
const max = Math.max(w, h, this.bitmap.width, this.bitmap.height);
this.resize(max, max, mode);
this.blit(
c,
this.bitmap.width / 2 - c.bitmap.width / 2,
this.bitmap.height / 2 - c.bitmap.height / 2
);
}
const bW = this.bitmap.width;
const bH = this.bitmap.height;
const dstBuffer = Buffer.alloc(this.bitmap.data.length);
function createTranslationFunction(deltaX, deltaY) {
return function(x, y) {
return {
x: x + deltaX,
y: y + deltaY
};
};
}
const translate2Cartesian = createTranslationFunction(-(bW / 2), -(bH / 2));
const translate2Screen = createTranslationFunction(
bW / 2 + 0.5,
bH / 2 + 0.5
);
for (let y = 1; y <= bH; y++) {
for (let x = 1; x <= bW; x++) {
const cartesian = translate2Cartesian(x, y);
const source = translate2Screen(
cosine * cartesian.x - sine * cartesian.y,
cosine * cartesian.y + sine * cartesian.x
);
const dstIdx = (bW * (y - 1) + x - 1) << 2;
if (source.x >= 0 && source.x < bW && source.y >= 0 && source.y < bH) {
const srcIdx = ((bW * (source.y | 0) + source.x) | 0) << 2;
const pixelRGBA = this.bitmap.data.readUInt32BE(srcIdx);
dstBuffer.writeUInt32BE(pixelRGBA, dstIdx);
} else {
// reset off-image pixels
dstBuffer.writeUInt32BE(this._background, dstIdx);
}
}
}
this.bitmap.data = dstBuffer;
if (mode === true || typeof mode === 'string') {
// now crop the image to the final size
const x = bW / 2 - w / 2;
const y = bH / 2 - h / 2;
this.crop(x, y, w, h);
}
}
export default () => ({
/**
* Rotates the image clockwise by a number of degrees. By default the width and height of the image will be resized appropriately.
* @param {number} deg the number of degrees to rotate the image by
* @param {string|boolean} mode (optional) resize mode or a boolean, if false then the width and height of the image will not be changed
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
* @returns {Jimp} this for chaining of methods
*/
rotate(deg, mode, cb) {
// enable overloading
if (typeof mode === 'undefined' || mode === null) {
// e.g. image.resize(120);
// e.g. image.resize(120, null, cb);
// e.g. image.resize(120, undefined, cb);
mode = true;
}
if (typeof mode === 'function' && typeof cb === 'undefined') {
// e.g. image.resize(120, cb);
cb = mode;
mode = true;
}
if (typeof deg !== 'number') {
return throwError.call(this, 'deg must be a number', cb);
}
if (typeof mode !== 'boolean' && typeof mode !== 'string') {
return throwError.call(this, 'mode must be a boolean or a string', cb);
}
advancedRotate.call(this, deg, mode, cb);
if (isNodePattern(cb)) {
cb.call(this, null, this);
}
return this;
}
});

View File

@@ -0,0 +1,636 @@
import { Jimp, mkJGD } from '@jimp/test-utils';
import configure from '@jimp/custom';
import blit from '@jimp/plugin-blit';
import crop from '@jimp/plugin-crop';
import resize from '@jimp/plugin-resize';
import rotate from '../src';
const jimp = configure({ plugins: [rotate, blit, crop, resize] }, Jimp);
describe('Rotate a image with even size', () => {
let imgSrc = null;
before(done => {
jimp
.read(
mkJGD(
'▰▴▴▴▪▪▪▰',
'▴▴▴▴▪▪▪▪',
'▴▴▴▴▪▪▪▪',
'▴▴▴▴▪▪▪▪',
'▪▪▪▪▴▴▴▴',
'▪▪▪▪▴▴▴▴',
'▪▪▪▪▴▴▴▴',
'▦▪▪▪▴▴▴▦'
)
)
.then(imgJimp => {
imgSrc = imgJimp;
done();
})
.catch(done);
});
it('1 degrees', () => {
imgSrc
.clone()
.rotate(1, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
'▰▴▴▴▪▪▪▰ ',
'▴▴▴▴▪▪▪▪ ',
'▴▴▴▴▪▪▪▪ ',
'▴▴▴▴▪▪▪▪ ',
'▪▪▪▪▴▴▴▴ ',
'▪▪▪▪▴▴▴▴ ',
'▪▪▪▪▴▴▴▴ ',
'▦▪▪▪▴▴▴▦ ',
' ',
' '
)
);
});
it('91 degrees', () => {
imgSrc
.clone()
.rotate(91, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ',
'▰▪▪▪▴▴▴▦ ',
'▪▪▪▪▴▴▴▴ ',
'▪▪▪▪▴▴▴▴ ',
'▪▪▪▪▴▴▴▴ ',
'▴▴▴▴▪▪▪▪ ',
'▴▴▴▴▪▪▪▪ ',
'▴▴▴▴▪▪▪▪ ',
'▰▴▴▴▪▪▪▦ ',
' '
)
);
});
it('30 degrees', () => {
imgSrc
.clone()
.rotate(30, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ▰▰ ',
' ▪▪▪▪ ',
' ▴▪▪▪▪▪ ',
'▴▴▴▴▪▪▪▪ ',
'▴▴▴▴▪▪▴▴▴ ',
'▴▴▴▴▪▴▴▴▴▴ ',
' ▴▴▪▪▴▴▴▴▦ ',
' ▪▪▪▪▪▴▴▴ ',
' ▪▪▪▪▪ ',
' ▪▪▪ ',
' ▦ ',
' '
)
);
});
it('45 degrees', () => {
imgSrc
.clone()
.rotate(45, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ',
' ▰ ',
' ▪▪▪ ',
' ▪▪▪▪▪ ',
' ▴▴▪▪▪▪▴ ',
' ▴▴▴▴▪▪▴▴▴ ',
'▰▰▴▴▴▴▴▴▴▴▦ ',
' ▴▴▴▴▪▪▴▴▴ ',
' ▴▴▪▪▪▪▴ ',
' ▪▪▪▪▪ ',
' ▪▪▪ ',
' ▦ ',
' ',
' '
)
);
});
it('60 degrees', () => {
imgSrc
.clone()
.rotate(60, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ▰ ',
' ▪▪▪ ',
' ▪▪▪▪▪ ',
' ▪▪▪▪▪▴▴▴ ',
' ▴▴▪▪▴▴▴▴▦ ',
'▴▴▴▴▪▴▴▴▴▴ ',
'▴▴▴▴▪▪▴▴▴ ',
'▴▴▴▴▪▪▪▪ ',
' ▴▪▪▪▪▪ ',
' ▪▪▪▪ ',
' ▦▦ ',
' '
)
);
});
it('90 degrees', () => {
imgSrc
.clone()
.rotate(90, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ',
'▰▪▪▪▴▴▴▦ ',
'▪▪▪▪▴▴▴▴ ',
'▪▪▪▪▴▴▴▴ ',
'▪▪▪▪▴▴▴▴ ',
'▴▴▴▴▪▪▪▪ ',
'▴▴▴▴▪▪▪▪ ',
'▴▴▴▴▪▪▪▪ ',
'▰▴▴▴▪▪▪▦ ',
' '
)
);
});
it('120 degrees', () => {
imgSrc
.clone()
.rotate(120, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ',
' ▴▦ ',
' ▴▴▴▴ ',
' ▪▪▴▴▴▴ ',
'▰▪▪▪▴▴▴▴▪ ',
'▰▪▪▪▪▴▴▪▪▪ ',
' ▪▪▪▪▪▪▪▪▪ ',
' ▪▪▴▴▴▪▪▪▪▦ ',
' ▴▴▴▴▴▪▪ ',
' ▴▴▴▴▪ ',
' ▴▴▴ ',
' '
)
);
});
it('135 degrees', () => {
imgSrc
.clone()
.rotate(135, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ',
' ',
' ▦ ',
' ▴▴▴ ',
' ▴▴▴▴▴ ',
' ▪▪▴▴▴▪▪ ',
' ▪▪▪▪▴▪▪▪▪ ',
' ▰▪▪▪▪▴▪▪▪▪▦ ',
' ▪▪▪▴▴▴▪▪▪ ',
' ▪▴▴▴▴▴▪ ',
' ▴▴▴▴▴ ',
' ▴▰▴ ',
' ▰ ',
' '
)
);
});
it('180 degrees', () => {
imgSrc
.clone()
.rotate(180, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ',
' ▦▴▴▴▪▪▪▦ ',
' ▴▴▴▴▪▪▪▪ ',
' ▴▴▴▴▪▪▪▪ ',
' ▴▴▴▴▪▪▪▪ ',
' ▪▪▪▪▴▴▴▴ ',
' ▪▪▪▪▴▴▴▴ ',
' ▪▪▪▪▴▴▴▴ ',
' ▰▪▪▪▴▴▴▰ ',
' '
)
);
});
it('225 degrees', () => {
imgSrc
.clone()
.rotate(225, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ',
' ▦ ',
' ▪▪▪ ',
' ▪▪▪▪▪ ',
' ▴▪▪▪▪▴▴ ',
' ▴▴▴▪▪▴▴▴▴ ',
' ▦▴▴▴▴▴▴▴▴▰▰ ',
' ▴▴▴▪▪▴▴▴▴ ',
' ▴▪▪▪▪▴▴ ',
' ▪▪▪▪▪ ',
' ▪▪▪ ',
' ▰ ',
' ',
' '
)
);
});
it('270 degrees', () => {
imgSrc
.clone()
.rotate(270, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ▦▪▪▪▴▴▴▰ ',
' ▪▪▪▪▴▴▴▴ ',
' ▪▪▪▪▴▴▴▴ ',
' ▪▪▪▪▴▴▴▴ ',
' ▴▴▴▴▪▪▪▪ ',
' ▴▴▴▴▪▪▪▪ ',
' ▴▴▴▴▪▪▪▪ ',
' ▦▴▴▴▪▪▪▰ ',
' ',
' '
)
);
});
it('315 degrees', () => {
imgSrc
.clone()
.rotate(315, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ▰ ',
' ▴▰▴ ',
' ▴▴▴▴▴ ',
' ▪▴▴▴▴▴▪ ',
' ▪▪▪▴▴▴▪▪▪ ',
' ▦▪▪▪▪▴▪▪▪▪▰ ',
' ▪▪▪▪▴▪▪▪▪ ',
' ▪▪▴▴▴▪▪ ',
' ▴▴▴▴▴ ',
' ▴▴▴ ',
' ▦ ',
' ',
' ',
' '
)
);
});
it('360 degrees', () => {
imgSrc
.clone()
.rotate(360, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
'▰▴▴▴▪▪▪▰ ',
'▴▴▴▴▪▪▪▪ ',
'▴▴▴▴▪▪▪▪ ',
'▴▴▴▴▪▪▪▪ ',
'▪▪▪▪▴▴▴▴ ',
'▪▪▪▪▴▴▴▴ ',
'▪▪▪▪▴▴▴▴ ',
'▦▪▪▪▴▴▴▦ ',
' ',
' '
)
);
});
});
describe('Rotate a image with odd size', () => {
let imgSrc = null;
before(done => {
jimp
.read(
mkJGD(
'▴▴▴▦▪▪▪',
'▴▴▴▦▪▪▪',
'▴▴▴▦▪▪▪',
'▦▦▦▦▦▦▦',
'▴▴▴▦▴▴▴',
'▴▴▴▦▴▴▴',
'▴▴▴▦▴▴▴'
)
)
.then(imgJimp => {
imgSrc = imgJimp;
done();
})
.catch(done);
});
it('45 degrees', () => {
imgSrc
.clone()
.rotate(45, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ',
' ▪ ',
' ▪▪▪ ',
' ▦▪▪▪▦ ',
' ▴▴▦▪▦▴▴ ',
' ▴▴▴▴▦▴▴▴▴ ',
' ▴▴▦▴▦▴▴ ',
' ▦▴▴▴▦ ',
' ▴▴▴ ',
' ▴ ',
' ',
' '
)
);
});
it('135 degrees', () => {
imgSrc
.clone()
.rotate(135, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ',
' ▴ ',
' ▴▴▴ ',
' ▦▴▴▴▦ ',
' ▪▪▦▴▦▴▴ ',
' ▪▪▪▪▦▴▴▴▴ ',
' ▪▪▦▴▦▴▴ ',
' ▦▴▴▴▦ ',
' ▴▴▴ ',
' ▴ ',
' ',
' '
)
);
});
it('225 degrees', () => {
imgSrc
.clone()
.rotate(225, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ',
' ▴ ',
' ▴▴▴ ',
' ▦▴▴▴▦ ',
' ▴▴▦▴▦▴▴ ',
' ▴▴▴▴▦▴▴▴▴ ',
' ▴▴▦▪▦▴▴ ',
' ▦▪▪▪▦ ',
' ▪▪▪ ',
' ▪ ',
' ',
' '
)
);
});
it('315 degrees', () => {
imgSrc
.clone()
.rotate(315, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ',
' ▴ ',
' ▴▴▴ ',
' ▦▴▴▴▦ ',
' ▴▴▦▴▦▪▪ ',
' ▴▴▴▴▦▪▪▪▪ ',
' ▴▴▦▴▦▪▪ ',
' ▦▴▴▴▦ ',
' ▴▴▴ ',
' ▴ ',
' ',
' '
)
);
});
});
describe('Rotate a non-square image', () => {
let imgSrc = null;
before(done => {
jimp
.read(mkJGD('▴▴▴▴▪▪▪▪', '▴▴▴▴▪▪▪▪', '▦▦▦▦▴▴▴▴', '▦▦▦▦▴▴▴▴'))
.then(imgJimp => {
imgSrc = imgJimp;
done();
})
.catch(done);
});
it('1 degrees', () => {
imgSrc
.clone()
.rotate(1, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
'▴▴▴▴▪▪▪▪ ',
'▴▴▴▴▪▪▪▪ ',
'▦▦▦▦▴▴▴▴ ',
'▦▦▦▦▴▴▴▴ ',
' ',
' '
)
);
});
it('10 degrees', () => {
imgSrc
.clone()
.rotate(10, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ▪ ',
' ▴▴▴▪▪▪▪ ',
'▴▴▴▴▪▪▪▴ ',
'▴▴▦▦▴▴▴▴ ',
'▦▦▦▦▴▴▴ ',
'▦▦ ',
' ',
' '
)
);
});
it('30 degrees', () => {
imgSrc
.clone()
.rotate(30, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ',
' ▪▪ ',
' ▪▪▪▪ ',
' ▴▴▪▪▴▴▴ ',
'▴▴▴▦▴▴▴ ',
'▴▴▦▦▴▴ ',
'▦▦▦▦ ',
' ▦ ',
' ',
' '
)
);
});
it('45 degrees', () => {
imgSrc
.clone()
.rotate(45, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ',
' ▪▪ ',
' ▪▪▪▴ ',
' ▴▪▪▴▴▴ ',
' ▴▴▴▴▴▴ ',
'▴▴▴▦▦▴ ',
'▴▴▦▦▦ ',
' ▦▦▦ ',
' ▦ ',
' '
)
);
});
it('90 degrees', () => {
imgSrc
.clone()
.rotate(90, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ',
'▪▪▴▴ ',
'▪▪▴▴ ',
'▪▪▴▴ ',
'▪▪▴▴ ',
'▴▴▦▦ ',
'▴▴▦▦ ',
'▴▴▦▦ ',
'▴▴▦▦ ',
' '
)
);
});
it('135 degrees', () => {
imgSrc
.clone()
.rotate(135, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ',
' ▴ ',
' ▴▴▴ ',
' ▪▪▴▴▴ ',
' ▪▪▪▴▦▦ ',
' ▪▪▴▦▦▦ ',
' ▴▴▴▦▦▦ ',
' ▴▴▴▦ ',
' ▴▴ ',
' '
)
);
});
it('180 degrees', () => {
imgSrc
.clone()
.rotate(180, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ',
' ▴▴▴▴▦▦▦▦ ',
' ▴▴▴▴▦▦▦▦ ',
' ▪▪▪▪▴▴▴▴ ',
' ▪▪▪▪▴▴▴▴ ',
' '
)
);
});
it('225 degrees', () => {
imgSrc
.clone()
.rotate(225, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ▦ ',
' ▦▦▦ ',
' ▦▦▦▴▴ ',
' ▴▦▦▴▴▴ ',
' ▴▴▴▴▴▴ ',
' ▴▴▴▪▪▴ ',
' ▴▪▪▪ ',
' ▪▪ ',
' ',
' '
)
);
});
it('315 degrees', () => {
imgSrc
.clone()
.rotate(315, true)
.getJGDSync()
.should.be.sameJGD(
mkJGD(
' ▴▴ ',
' ▦▴▴▴ ',
'▦▦▦▴▴▴ ',
' ▦▦▦▴▪▪ ',
' ▦▦▴▪▪▪ ',
' ▴▴▴▪▪ ',
' ▴▴▴ ',
' ▴ ',
' ',
' '
)
);
});
});