Add lightness option to modulate operation

This commit is contained in:
Tenpi
2021-08-16 22:50:17 -04:00
committed by Lovell Fuller
parent 104464c2e0
commit 4a9267ce12
10 changed files with 62 additions and 13 deletions

View File

@@ -18,7 +18,9 @@ describe('Modulate', function () {
{ saturation: null },
{ hue: '50deg' },
{ hue: 1.5 },
{ hue: null }
{ hue: null },
{ lightness: '+50' },
{ lightness: null }
].forEach(function (options) {
it('should throw', function () {
assert.throws(function () {
@@ -108,6 +110,22 @@ describe('Modulate', function () {
assert.deepStrictEqual({ r: 127, g: 83, b: 81 }, { r, g, b });
});
it('should be able to lighten', async () => {
const [r, g, b] = await sharp({
create: {
width: 1,
height: 1,
channels: 3,
background: { r: 153, g: 68, b: 68 }
}
})
.modulate({ lightness: 10 })
.raw()
.toBuffer();
assert.deepStrictEqual({ r: 182, g: 93, b: 92 }, { r, g, b });
});
it('should be able to modulate all channels', async () => {
const [r, g, b] = await sharp({
create: {