Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MR414N-ID
GitHub Repository: MR414N-ID/botku2
Path: blob/master/node_modules/@jimp/plugin-circle/test/circle.test.js
1126 views
1
import { Jimp, mkJGD, getTestDir } from '@jimp/test-utils';
2
import configure from '@jimp/custom';
3
4
import circle from '../src';
5
6
const jimp = configure({ plugins: [circle] }, Jimp);
7
8
describe('Circle', () => {
9
it('makes a circle based on image height and width', async () => {
10
const expectedImg = await Jimp.read(
11
getTestDir(__dirname) + '/images/circled.png'
12
);
13
const imgSrc = await jimp.read(
14
mkJGD(
15
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
16
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
17
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
18
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
19
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
20
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
21
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
22
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
23
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
24
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦'
25
)
26
);
27
28
imgSrc.circle().bitmap.data.should.be.deepEqual(expectedImg.bitmap.data);
29
});
30
31
it('makes a circle using provided radius', async () => {
32
const expectedImg = await Jimp.read(
33
getTestDir(__dirname) + '/images/radius-3-circle.png'
34
);
35
const imgSrc = await jimp.read(
36
mkJGD(
37
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
38
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
39
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
40
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
41
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
42
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
43
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
44
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
45
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
46
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦'
47
)
48
);
49
50
imgSrc
51
.circle({ radius: 3 })
52
.bitmap.data.should.be.deepEqual(expectedImg.bitmap.data);
53
});
54
55
it('should ', async () => {
56
const expectedImg = await Jimp.read(
57
getTestDir(__dirname) + '/images/x-y-circle.png'
58
);
59
const imgSrc = await jimp.read(
60
mkJGD(
61
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
62
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
63
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
64
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
65
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
66
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
67
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
68
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
69
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦',
70
'▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦'
71
)
72
);
73
74
imgSrc
75
.circle({ radius: 5, x: 5, y: 5 })
76
.bitmap.data.should.be.deepEqual(expectedImg.bitmap.data);
77
});
78
});
79
80