File tree Expand file tree Collapse file tree 2 files changed +22
-5
lines changed
Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 66 */
77
88import { describe , expect , it , vi } from 'vitest' ;
9- import { BlurFilter , Sprite , Texture } from 'pixi.js' ;
9+ import { BlurFilter , Sprite , Texture , Graphics } from 'pixi.js' ;
1010import { VisualMixin } from './visual' ;
1111import { Keyframe } from '../../models' ;
1212import { Clip } from '../clip' ;
1313import { Composition } from '../../composition' ;
14+ import { CircleMask } from '../mask' ;
1415
1516describe ( 'The Visual Clip Mixin' , ( ) => {
1617 const VisualClip = VisualMixin ( Clip ) ;
@@ -116,4 +117,23 @@ describe('The Visual Clip Mixin', () => {
116117 expect ( exitSpy ) . toHaveBeenCalledTimes ( 1 ) ;
117118 expect ( clip . view . filters ) . toBeNull ( ) ;
118119 } ) ;
120+
121+ it ( 'should add a mask to the view' , async ( ) => {
122+ const clip = new VisualClip ( ) ;
123+
124+ expect ( clip . mask ) . toBeUndefined ( ) ;
125+ expect ( clip . view . mask ) . toBeUndefined ( ) ;
126+
127+ clip . mask = new CircleMask ( {
128+ radius : 1080 / 2 ,
129+ position : {
130+ x : 1920 / 2 ,
131+ y : 1080 / 2 ,
132+ } ,
133+ } ) ;
134+
135+ expect ( clip . mask ) . toBeInstanceOf ( CircleMask ) ;
136+ expect ( clip . view . mask ) . toBeInstanceOf ( Graphics ) ;
137+ } ) ;
138+
119139} ) ;
Original file line number Diff line number Diff line change @@ -27,8 +27,6 @@ export function VisualMixin<T extends Constructor<BaseClass>>(Base: T) {
2727 */
2828 public filters ?: Filter | Filter [ ] ;
2929
30- private _mask ?: Graphics ;
31-
3230 @serializable ( deserializers . Deserializer1D )
3331 public _height ?: int | Keyframe < int > | Percent | NumberCallback ;
3432
@@ -179,11 +177,10 @@ export function VisualMixin<T extends Constructor<BaseClass>>(Base: T) {
179177 * The mask to apply to the clip
180178 */
181179 public get mask ( ) : Graphics | undefined {
182- return this . _mask ;
180+ return this . view . mask as Graphics | undefined ;
183181 }
184182
185183 public set mask ( value : Graphics | undefined ) {
186- this . _mask = value ;
187184 this . view . mask = value ?? null ;
188185 }
189186
You can’t perform that action at this time.
0 commit comments