feat: add alpha and morphology core tools

This commit is contained in:
2026-08-24 12:02:42 +05:00
parent b434bf3ef3
commit cb5ccf6da8
4 changed files with 389 additions and 0 deletions
+17
View File
@@ -3,6 +3,7 @@ import {
colorMask,
extractAlphaMask,
flattenOntoColor,
hardenAlpha,
invertAlpha,
parseHex,
removeColorToAlpha,
@@ -11,6 +12,22 @@ import {
} from './alpha';
import { makeImage } from './test-helpers';
describe('hardenAlpha', () => {
it('бинаризует альфу по порогу, RGB не трогает', () => {
const out = hardenAlpha(
makeImage(2, 1, [
[10, 20, 30, 100],
[40, 50, 60, 200]
]),
50
);
expect([...out.data]).toEqual([
10, 20, 30, 0,
40, 50, 60, 255
]);
});
});
describe('setAlphaChannel', () => {
it('задаёт константную альфу', () => {
const out = setAlphaChannel(makeImage(2, 1, [