Path: blob/master/node_modules/@jimp/plugin-fisheye/test/fisheye.test.js
2593 views
import { Jimp, mkJGD } from '@jimp/test-utils';1import configure from '@jimp/custom';23import fisheye from '../src';45const jimp = configure({ plugins: [fisheye] }, Jimp);67describe('Fisheye', () => {8it('should create fisheye lens to image', async () => {9const imgNormal = await jimp.read(10mkJGD(11'0000000000',12'0001221000',13'0022222200',14'0122112210',15'0221001220',16'0221001220',17'0122112210',18'0022222200',19'0001221000',20'0000000000'21)22);23const imgBulged = await jimp.read(24mkJGD(25'0001221000',26'0221112220',27'0220000121',28'1100000112',29'2100000012',30'2100000012',31'1200000012',32'0211000222',33'0221111220',34'0012222200'35)36);3738imgNormal39.fisheye()40.getJGDSync()41.should.be.sameJGD(imgBulged.getJGDSync());42});4344it('should create fisheye lens to image with radius', async () => {45const imgNormal = await jimp.read(46mkJGD(47'0000000000',48'0000000000',49'0000000000',50'0000000000',51'0001111000',52'0001111000',53'0000000000',54'0000000000',55'0000000000',56'0000000000'57)58);59const imgBulged = await jimp.read(60mkJGD(61'■■■■■■■■■■',62'■■■■■■■■■■',63'■■■■■■■■■■',64'■■■11111■■',65'■■111111■■',66'■■111111■■',67'■■■■111■■■',68'■■■■■■■■■■',69'■■■■■■■■■■',70'■■■■■■■■■■'71)72);7374imgNormal75.fisheye({ r: 1.8 })76.getJGDSync()77.should.be.sameJGD(imgBulged.getJGDSync());78});79});808182