feat: add core tools - transfor, light, effects

This commit is contained in:
2026-08-24 17:09:39 +05:00
parent b6e157e5da
commit 7ef4b908e2
7 changed files with 411 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
import { describe, expect, it } from 'vitest';
import { vignette } from './effects';
import { makeImage } from './test-helpers';
describe('vignette', () => {
it('сила 0 — идентичное преобразование', () => {
const img = makeImage(3, 3, new Array(9).fill([200, 100, 50, 255]));
expect([...vignette(img, 0).data]).toEqual([...img.data]);
});
it('углы темнее центра', () => {
const img = makeImage(7, 7, new Array(49).fill([200, 200, 200, 255]));
const out = vignette(img, 80);
const centerR = out.data[(3 * 7 + 3) * 4];
const cornerR = out.data[0];
expect(cornerR).toBeLessThan(centerR);
expect(centerR).toBeGreaterThan(150);
});
});