File tree Expand file tree Collapse file tree 3 files changed +27
-1
lines changed
Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import {Transformation} from "../../../src";
22import { Effect } from "../../../src/actions/effect" ;
33import { halftone4x4Orthogonal } from "../../../src/qualifiers/dither" ;
44import { rodMonochromacy } from "../../../src/qualifiers/simulateColorBlind" ;
5+ import { Region } from "../../../src/qualifiers" ;
56
67
78describe ( 'Effect toJson()' , ( ) => {
@@ -268,4 +269,17 @@ describe('Effect toJson()', () => {
268269 }
269270 ] ) ;
270271 } ) ;
272+
273+
274+ it ( 'effect.pixelate' , ( ) => {
275+ const transformation = new Transformation ( )
276+ . addAction ( Effect . pixelate ( ) . squareSize ( 15 ) . region ( Region . faces ( ) ) ) ;
277+ expect ( transformation . toJson ( ) ) . toStrictEqual ( [
278+ {
279+ actionType : 'pixelate' ,
280+ squareSize : 15 ,
281+ region : { RegionType : 'faces' }
282+ }
283+ ] ) ;
284+ } ) ;
271285} ) ;
Original file line number Diff line number Diff line change 11import { NamedRegion } from "../../../qualifiers/region/NamedRegion.js" ;
22import { Qualifier } from "../../../internal/qualifier/Qualifier.js" ;
33import { Action } from "../../../internal/Action.js" ;
4+ import { IPixelateModel } from "../../../internal/models/IEffectActionModel.js" ;
45
56/**
67 * @description The Action class of the pixelate Builder
@@ -11,10 +12,13 @@ import {Action} from "../../../internal/Action.js";
1112class Pixelate extends Action {
1213 private _region ?: NamedRegion ;
1314 private _squareSize : number | string ;
15+ protected _actionModel : IPixelateModel = { } ;
1416
1517 constructor ( squareSize : number | string ) {
1618 super ( ) ;
1719 this . _squareSize = squareSize ;
20+ this . _actionModel . actionType = 'pixelate' ;
21+ this . _actionModel . squareSize = squareSize as number ;
1822 }
1923
2024 /**
@@ -23,6 +27,7 @@ class Pixelate extends Action {
2327 */
2428 region ( pixelateRegion : NamedRegion ) : this {
2529 this . _region = pixelateRegion ;
30+ this . _actionModel . region = { RegionType : this . _region . regionType }
2631 return this ;
2732 }
2833
@@ -32,6 +37,7 @@ class Pixelate extends Action {
3237 */
3338 squareSize ( squareSize : number | string ) : this {
3439 this . _squareSize = squareSize ;
40+ this . _actionModel . squareSize = squareSize as number ;
3541 return this ;
3642 }
3743
Original file line number Diff line number Diff line change @@ -68,6 +68,11 @@ interface IDeshakeEffectModel extends IActionModel{
6868 pixels ?: number ;
6969}
7070
71+ interface IPixelateModel extends IActionModel {
72+ squareSize ?: number ;
73+ region ?: { RegionType ?: string } ;
74+ }
75+
7176export {
7277 IEffectActionWithLevelModel ,
7378 ISimpleEffectActionModel ,
@@ -81,5 +86,6 @@ export {
8186 IGradientFadeEffecModel ,
8287 IAssistColorBlindEffectModel ,
8388 ISimulateColorBlindEffectModel ,
84- IDeshakeEffectModel
89+ IDeshakeEffectModel ,
90+ IPixelateModel
8591} ;
You can’t perform that action at this time.
0 commit comments