@jimp/plugin-blit
Advanced tools
Comparing version 0.21.3 to 0.21.4--canary.1163.a26f5b300ee88c2fadb9909dd390cb4380b32a42.0
{ | ||
"name": "@jimp/plugin-blit", | ||
"version": "0.21.3", | ||
"version": "0.21.4--canary.1163.a26f5b300ee88c2fadb9909dd390cb4380b32a42.0", | ||
"description": "Blit an image.", | ||
@@ -10,3 +10,3 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"test": "cross-env BABEL_ENV=test mocha --require @babel/register", | ||
"test": "cross-env BABEL_ENV=test mocha --require @babel/register --recursive test --extension js", | ||
"test:watch": "npm run test -- --reporter min --watch", | ||
@@ -25,8 +25,8 @@ "test:coverage": "nyc npm run test", | ||
"dependencies": { | ||
"@jimp/utils": "^0.21.3" | ||
"@jimp/utils": "0.21.4--canary.1163.a26f5b300ee88c2fadb9909dd390cb4380b32a42.0" | ||
}, | ||
"devDependencies": { | ||
"@jimp/custom": "^0.21.3", | ||
"@jimp/jpeg": "^0.21.3", | ||
"@jimp/test-utils": "^0.21.3" | ||
"@jimp/custom": "0.21.4--canary.1163.a26f5b300ee88c2fadb9909dd390cb4380b32a42.0", | ||
"@jimp/jpeg": "0.21.4--canary.1163.a26f5b300ee88c2fadb9909dd390cb4380b32a42.0", | ||
"@jimp/test-utils": "0.21.4--canary.1163.a26f5b300ee88c2fadb9909dd390cb4380b32a42.0" | ||
}, | ||
@@ -39,3 +39,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "046ea0d26952611c74bebd7b13877eb628458aa3" | ||
"gitHead": "a26f5b300ee88c2fadb9909dd390cb4380b32a42" | ||
} |
import { Jimp, mkJGD, getTestDir } from "@jimp/test-utils"; | ||
import jpeg from "@jimp/jpeg"; | ||
import configure from "@jimp/custom"; | ||
import expect from "@storybook/expect"; | ||
import blit from "../src"; | ||
import { expectToBeJGD } from "@jimp/test-utils/src"; | ||
@@ -47,113 +49,95 @@ const jimp = configure({ types: [jpeg], plugins: [blit] }, Jimp); | ||
it("blit on top, with no crop", () => { | ||
targetImg | ||
.clone() | ||
.blit(srcImg, 0, 0) | ||
.getJGDSync() | ||
.should.be.sameJGD( | ||
mkJGD( | ||
"□□□□□□▸▸", | ||
"□▥▥▥▥□▸▸", | ||
"□▥■■▥□▸▸", | ||
"□▥■■▥□▸▸", | ||
"□▥▥▥▥□◆◆", | ||
"□□□□□□◆◆", | ||
"▾▾▾▾◆◆◆◆", | ||
"▾▾▾▾◆◆◆◆" | ||
) | ||
); | ||
expectToBeJGD( | ||
targetImg.clone().blit(srcImg, 0, 0).getJGDSync(), | ||
mkJGD( | ||
"□□□□□□▸▸", | ||
"□▥▥▥▥□▸▸", | ||
"□▥■■▥□▸▸", | ||
"□▥■■▥□▸▸", | ||
"□▥▥▥▥□◆◆", | ||
"□□□□□□◆◆", | ||
"▾▾▾▾◆◆◆◆", | ||
"▾▾▾▾◆◆◆◆" | ||
) | ||
); | ||
}); | ||
it("blit on middle, with no crop", () => { | ||
targetImg | ||
.clone() | ||
.blit(srcImg, 1, 1) | ||
.getJGDSync() | ||
.should.be.sameJGD( | ||
mkJGD( | ||
"▴▴▴▴▸▸▸▸", | ||
"▴□□□□□□▸", | ||
"▴□▥▥▥▥□▸", | ||
"▴□▥■■▥□▸", | ||
"▾□▥■■▥□◆", | ||
"▾□▥▥▥▥□◆", | ||
"▾□□□□□□◆", | ||
"▾▾▾▾◆◆◆◆" | ||
) | ||
); | ||
expectToBeJGD( | ||
targetImg.clone().blit(srcImg, 1, 1).getJGDSync(), | ||
mkJGD( | ||
"▴▴▴▴▸▸▸▸", | ||
"▴□□□□□□▸", | ||
"▴□▥▥▥▥□▸", | ||
"▴□▥■■▥□▸", | ||
"▾□▥■■▥□◆", | ||
"▾□▥▥▥▥□◆", | ||
"▾□□□□□□◆", | ||
"▾▾▾▾◆◆◆◆" | ||
) | ||
); | ||
}); | ||
it("blit on middle, with x,y crop", () => { | ||
targetImg | ||
.clone() | ||
.blit(srcImg, 2, 2, 1, 1, 5, 5) | ||
.getJGDSync() | ||
.should.be.sameJGD( | ||
mkJGD( | ||
"▴▴▴▴▸▸▸▸", | ||
"▴▴▴▴▸▸▸▸", | ||
"▴▴▥▥▥▥□▸", | ||
"▴▴▥■■▥□▸", | ||
"▾▾▥■■▥□◆", | ||
"▾▾▥▥▥▥□◆", | ||
"▾▾□□□□□◆", | ||
"▾▾▾▾◆◆◆◆" | ||
) | ||
); | ||
expectToBeJGD( | ||
targetImg.clone().blit(srcImg, 2, 2, 1, 1, 5, 5).getJGDSync(), | ||
mkJGD( | ||
"▴▴▴▴▸▸▸▸", | ||
"▴▴▴▴▸▸▸▸", | ||
"▴▴▥▥▥▥□▸", | ||
"▴▴▥■■▥□▸", | ||
"▾▾▥■■▥□◆", | ||
"▾▾▥▥▥▥□◆", | ||
"▾▾□□□□□◆", | ||
"▾▾▾▾◆◆◆◆" | ||
) | ||
); | ||
}); | ||
it("blit on middle, with x,y,w,h crop", () => { | ||
targetImg | ||
.clone() | ||
.blit(srcImg, 2, 2, 1, 1, 4, 4) | ||
.getJGDSync() | ||
.should.be.sameJGD( | ||
mkJGD( | ||
"▴▴▴▴▸▸▸▸", | ||
"▴▴▴▴▸▸▸▸", | ||
"▴▴▥▥▥▥▸▸", | ||
"▴▴▥■■▥▸▸", | ||
"▾▾▥■■▥◆◆", | ||
"▾▾▥▥▥▥◆◆", | ||
"▾▾▾▾◆◆◆◆", | ||
"▾▾▾▾◆◆◆◆" | ||
) | ||
); | ||
expectToBeJGD( | ||
targetImg.clone().blit(srcImg, 2, 2, 1, 1, 4, 4).getJGDSync(), | ||
mkJGD( | ||
"▴▴▴▴▸▸▸▸", | ||
"▴▴▴▴▸▸▸▸", | ||
"▴▴▥▥▥▥▸▸", | ||
"▴▴▥■■▥▸▸", | ||
"▾▾▥■■▥◆◆", | ||
"▾▾▥▥▥▥◆◆", | ||
"▾▾▾▾◆◆◆◆", | ||
"▾▾▾▾◆◆◆◆" | ||
) | ||
); | ||
}); | ||
it("blit partially out, on top-left", () => { | ||
targetImg | ||
.clone() | ||
.blit(srcImg, -1, -1) | ||
.getJGDSync() | ||
.should.be.sameJGD( | ||
mkJGD( | ||
"▥▥▥▥□▸▸▸", | ||
"▥■■▥□▸▸▸", | ||
"▥■■▥□▸▸▸", | ||
"▥▥▥▥□▸▸▸", | ||
"□□□□□◆◆◆", | ||
"▾▾▾▾◆◆◆◆", | ||
"▾▾▾▾◆◆◆◆", | ||
"▾▾▾▾◆◆◆◆" | ||
) | ||
); | ||
expectToBeJGD( | ||
targetImg.clone().blit(srcImg, -1, -1).getJGDSync(), | ||
mkJGD( | ||
"▥▥▥▥□▸▸▸", | ||
"▥■■▥□▸▸▸", | ||
"▥■■▥□▸▸▸", | ||
"▥▥▥▥□▸▸▸", | ||
"□□□□□◆◆◆", | ||
"▾▾▾▾◆◆◆◆", | ||
"▾▾▾▾◆◆◆◆", | ||
"▾▾▾▾◆◆◆◆" | ||
) | ||
); | ||
}); | ||
it("blit partially out, on bottom-right", () => { | ||
targetImg | ||
.clone() | ||
.blit(srcImg, 3, 3) | ||
.getJGDSync() | ||
.should.be.sameJGD( | ||
mkJGD( | ||
"▴▴▴▴▸▸▸▸", | ||
"▴▴▴▴▸▸▸▸", | ||
"▴▴▴▴▸▸▸▸", | ||
"▴▴▴□□□□□", | ||
"▾▾▾□▥▥▥▥", | ||
"▾▾▾□▥■■▥", | ||
"▾▾▾□▥■■▥", | ||
"▾▾▾□▥▥▥▥" | ||
) | ||
); | ||
expectToBeJGD( | ||
targetImg.clone().blit(srcImg, 3, 3).getJGDSync(), | ||
mkJGD( | ||
"▴▴▴▴▸▸▸▸", | ||
"▴▴▴▴▸▸▸▸", | ||
"▴▴▴▴▸▸▸▸", | ||
"▴▴▴□□□□□", | ||
"▾▾▾□▥▥▥▥", | ||
"▾▾▾□▥■■▥", | ||
"▾▾▾□▥■■▥", | ||
"▾▾▾□▥▥▥▥" | ||
) | ||
); | ||
}); | ||
@@ -166,5 +150,3 @@ | ||
image | ||
.blit(dice, 0, 0) | ||
.bitmap.data.should.be.deepEqual(expectedImg.bitmap.data); | ||
expect(image.blit(dice, 0, 0).bitmap.data).toEqual(expectedImg.bitmap.data); | ||
}); | ||
@@ -223,4 +205,5 @@ | ||
const small = await createCat(0.3, 1); | ||
small.bitmap.data.should.be.deepEqual(expectedSmall.bitmap.data); | ||
expect(small.bitmap.data).toEqual(expectedSmall.bitmap.data); | ||
const expectedMedium = await Jimp.read( | ||
@@ -230,3 +213,3 @@ testDir + "/images/cat-results/medium-cat.png" | ||
const medium = await createCat(0.6, 7); | ||
medium.bitmap.data.should.be.deepEqual(expectedMedium.bitmap.data); | ||
expect(medium.bitmap.data).toEqual(expectedMedium.bitmap.data); | ||
@@ -237,4 +220,4 @@ const expectedLarge = await Jimp.read( | ||
const large = await createCat(0.9, 20); | ||
large.bitmap.data.should.be.deepEqual(expectedLarge.bitmap.data); | ||
expect(large.bitmap.data).toEqual(expectedLarge.bitmap.data); | ||
}); | ||
}); |
731831
458
+ Added@jimp/utils@0.21.4--canary.1163.a26f5b300ee88c2fadb9909dd390cb4380b32a42.0(transitive)
- Removed@jimp/utils@0.21.3(transitive)
Updated@jimp/utils@0.21.4--canary.1163.a26f5b300ee88c2fadb9909dd390cb4380b32a42.0