@@ -219,11 +219,12 @@ class CanvasConstructor {
219219 * @chainable
220220 */
221221 addImage ( buffer , x , y , width , height , options = { } ) {
222+ this . save ( ) ;
222223 if ( options . type ) {
223- if ( options . type === 'round' ) return this . addRoundImage ( buffer , x , y , width , height , options . radius ) ;
224- if ( options . type === 'bevel' ) return this . addBevelImage ( buffer , x , y , width , height , options . radius ) ;
224+ if ( isNaN ( options . radius ) ) options . radius = 10 ;
225+ if ( options . type === 'round' ) this . createRoundClip ( x + options . radius , y + options . radius , options . radius ) ;
226+ if ( options . type === 'bevel' ) this . createBeveledClip ( x , y , width , height , options . radius ) ;
225227 }
226- this . save ( ) ;
227228 const image = new Canvas . Image ( ) ;
228229 image . onload = ( ) => this . context . drawImage ( image , x , y , width , height ) ;
229230 image . src = buffer ;
@@ -242,8 +243,7 @@ class CanvasConstructor {
242243 * @chainable
243244 */
244245 addRoundImage ( buffer , x , y , width , height , radius ) {
245- this . createRoundClip ( x + radius , y + radius , radius ) ;
246- return this . addImage ( buffer , x , y , width , height , { } ) ;
246+ return this . addImage ( buffer , x , y , width , height , { type : 'round' , radius } ) ;
247247 }
248248
249249 /**
@@ -258,8 +258,7 @@ class CanvasConstructor {
258258 * @chainable
259259 */
260260 addBevelImage ( buffer , x , y , width , height , radius ) {
261- this . createBeveledClip ( x , y , width , height , radius ) ;
262- return this . addImage ( buffer , x , y , width , height , { } ) ;
261+ return this . addImage ( buffer , x , y , width , height , { type : 'bevel' , radius } ) ;
263262 }
264263
265264 /**
0 commit comments