-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathset-area.spec.ts
34 lines (28 loc) · 1.09 KB
/
set-area.spec.ts
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
/* Copyright Dirk Lemstra https://github.com/dlemstra/Magick.WASM */
import { ImageMagick } from '../../../src/image-magick';
import { MagickColors } from '../../../src/magick-colors';
import { MagickImage } from '../../../src/magick-image';
import { PixelCollection } from '../../../src/pixels/pixel-collection';
import { colorAssert } from '../../color-assert';
let image: MagickImage;
let pixels: PixelCollection;
beforeEach(() => {
ImageMagick._api = (global as any).native;
image = MagickImage.create();
image.read('logo:');
pixels = PixelCollection._create(image);
});
afterEach(() => {
pixels.dispose();
image.dispose();
});
describe('PixelCollection#setArea', () => {
it('should set the pixels at the specified location', () => {
const data = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ];
pixels.setArea(0, 0, 2, 2, data);
colorAssert(image, 0, 0, MagickColors.Black);
colorAssert(image, 0, 1, MagickColors.Black);
colorAssert(image, 1, 0, MagickColors.Black);
colorAssert(image, 1, 1, MagickColors.Black);
});
});