mirror of
https://github.com/Ku6epXBOCTuK/easy-png-tools.git
synced 2026-09-14 21:46:35 +00:00
feat: add alpha and morphology core tools
This commit is contained in:
@@ -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, [
|
||||
|
||||
Reference in New Issue
Block a user