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