File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,25 @@ suite('p5.Image', function() {
119
119
}
120
120
} ) ;
121
121
122
+ test ( 'it should mask images from createGraphics' , function ( ) {
123
+ myp5 . createCanvas ( 10 , 10 ) ;
124
+ myp5 . pixelDensity ( 2 ) ;
125
+ let img = myp5 . createGraphics ( 10 , 10 ) ;
126
+ img . rect ( 0 , 0 , 10 , 10 ) ;
127
+ img . background ( 0 ) ;
128
+ let mask = createGraphics ( 10 , 10 ) ;
129
+ mask . rect ( 0 , 0 , 5 , 5 ) ;
130
+ let masked = img . get ( ) ;
131
+ masked . mask ( mask . get ( ) ) ;
132
+
133
+ for ( let i = 0 ; i < masked . width ; i ++ ) {
134
+ for ( let j = 0 ; j < masked . height ; j ++ ) {
135
+ let alpha = i < 5 && j < 5 ? 255 : 0 ;
136
+ assert . strictEqual ( masked . get ( i , j ) [ 3 ] , alpha ) ;
137
+ }
138
+ }
139
+ } ) ;
140
+
122
141
test ( 'it should mask the animated gif image' , function ( ) {
123
142
const imagePath = 'unit/assets/nyan_cat.gif' ;
124
143
return new Promise ( function ( resolve , reject ) {
You can’t perform that action at this time.
0 commit comments