Skip to content

Commit cbf66e2

Browse files
committed
add improve toJson
1 parent af95846 commit cbf66e2

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {Transformation} from "../../../src";
2+
import {Adjust} from "../../../src/actions/adjust";
3+
4+
describe('Adjust toJson()', () => {
5+
it('adjust.improve', () => {
6+
const transformation = new Transformation()
7+
.addAction(Adjust.improve().mode('outdoor').blend(50));
8+
expect(transformation.toJson()).toStrictEqual( [
9+
{
10+
actionType: 'improve',
11+
mode: 'outdoor',
12+
blend: 50
13+
}
14+
]);
15+
});
16+
});

src/actions/adjust/ImproveAction.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {Action} from "../../internal/Action.js";
22
import {QualifierValue} from "../../internal/qualifier/QualifierValue.js";
33
import {Qualifier} from "../../internal/qualifier/Qualifier.js";
44
import {stringOrNumber} from "../../types/types.js";
5+
import {ImproveActionModel} from "../../internal/models/IAdjustActionModel";
56

67
/**
78
* @description Defines how to improve an image by automatically adjusting image colors, contrast and brightness.</br>
@@ -11,6 +12,7 @@ import {stringOrNumber} from "../../types/types.js";
1112
class ImproveAction extends Action {
1213
private modeValue:stringOrNumber;
1314
private blendValue:number;
15+
protected _actionModel: ImproveActionModel = {actionType: 'improve'};
1416
constructor() {
1517
super();
1618
}
@@ -22,6 +24,7 @@ class ImproveAction extends Action {
2224
*/
2325
mode(value: 'outdoor' | 'indoor' | string): this {
2426
this.modeValue = value;
27+
this._actionModel.mode = value;
2528
return this;
2629
}
2730

@@ -31,6 +34,7 @@ class ImproveAction extends Action {
3134
*/
3235
blend(value:number): this {
3336
this.blendValue = value;
37+
this._actionModel.blend = value;
3438
return this;
3539
}
3640

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {IActionModel} from "./IActionModel.js";
2+
3+
interface ImproveActionModel extends IActionModel {
4+
mode?: string;
5+
blend?: number;
6+
}
7+
8+
export {ImproveActionModel};

0 commit comments

Comments
 (0)