Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jajbshjahavahh
GitHub Repository: jajbshjahavahh/Gojo-Satoru
Path: blob/master/node_modules/@jimp/plugin-fisheye/test/fisheye.test.js
2593 views
1
import { Jimp, mkJGD } from '@jimp/test-utils';
2
import configure from '@jimp/custom';
3
4
import fisheye from '../src';
5
6
const jimp = configure({ plugins: [fisheye] }, Jimp);
7
8
describe('Fisheye', () => {
9
it('should create fisheye lens to image', async () => {
10
const imgNormal = await jimp.read(
11
mkJGD(
12
'0000000000',
13
'0001221000',
14
'0022222200',
15
'0122112210',
16
'0221001220',
17
'0221001220',
18
'0122112210',
19
'0022222200',
20
'0001221000',
21
'0000000000'
22
)
23
);
24
const imgBulged = await jimp.read(
25
mkJGD(
26
'0001221000',
27
'0221112220',
28
'0220000121',
29
'1100000112',
30
'2100000012',
31
'2100000012',
32
'1200000012',
33
'0211000222',
34
'0221111220',
35
'0012222200'
36
)
37
);
38
39
imgNormal
40
.fisheye()
41
.getJGDSync()
42
.should.be.sameJGD(imgBulged.getJGDSync());
43
});
44
45
it('should create fisheye lens to image with radius', async () => {
46
const imgNormal = await jimp.read(
47
mkJGD(
48
'0000000000',
49
'0000000000',
50
'0000000000',
51
'0000000000',
52
'0001111000',
53
'0001111000',
54
'0000000000',
55
'0000000000',
56
'0000000000',
57
'0000000000'
58
)
59
);
60
const imgBulged = await jimp.read(
61
mkJGD(
62
'■■■■■■■■■■',
63
'■■■■■■■■■■',
64
'■■■■■■■■■■',
65
'■■■11111■■',
66
'■■111111■■',
67
'■■111111■■',
68
'■■■■111■■■',
69
'■■■■■■■■■■',
70
'■■■■■■■■■■',
71
'■■■■■■■■■■'
72
)
73
);
74
75
imgNormal
76
.fisheye({ r: 1.8 })
77
.getJGDSync()
78
.should.be.sameJGD(imgBulged.getJGDSync());
79
});
80
});
81
82