@@ -34,7 +34,7 @@ export interface DrawRectangleOptions<OutType> {
34
34
* Rectangle fill color array of N elements (e.g. R, G, B or G, A), N being the number of channels.
35
35
*
36
36
*/
37
- fillColor ?: number [ ] ;
37
+ fillColor ?: number [ ] | 'none' ;
38
38
/**
39
39
* Image to which the resulting image has to be put.
40
40
*/
@@ -65,7 +65,7 @@ export function drawRectangle(
65
65
width = image . width ,
66
66
height = image . height ,
67
67
strokeColor : color = getDefaultColor ( image ) ,
68
- fillColor : fill ,
68
+ fillColor,
69
69
} = options ;
70
70
const { column, row } = origin ;
71
71
@@ -96,16 +96,18 @@ export function drawRectangle(
96
96
newImage . setVisiblePixel ( column , currentRow , color ) ;
97
97
newImage . setVisiblePixel ( column + width - 1 , currentRow , color ) ;
98
98
99
- if ( fill ) {
99
+ if ( fillColor ) {
100
+ if ( fillColor === 'none' ) continue ;
100
101
for ( let col = column + 1 ; col < column + width - 1 ; col ++ ) {
101
- newImage . setVisiblePixel ( col , currentRow , fill ) ;
102
- newImage . setVisiblePixel ( col , currentRow , fill ) ;
102
+ newImage . setVisiblePixel ( col , currentRow , fillColor ) ;
103
+ newImage . setVisiblePixel ( col , currentRow , fillColor ) ;
103
104
}
104
105
}
105
106
}
106
107
}
107
108
// color is none but fill is defined
108
- else if ( fill ) {
109
+ else if ( fillColor ) {
110
+ if ( fillColor === 'none' ) return newImage ;
109
111
for (
110
112
let currentRow = row + 1 ;
111
113
currentRow < row + height - 1 ;
@@ -116,8 +118,8 @@ export function drawRectangle(
116
118
currentColumn < column + width - 1 ;
117
119
currentColumn ++
118
120
) {
119
- newImage . setVisiblePixel ( currentColumn , currentRow , fill ) ;
120
- newImage . setVisiblePixel ( currentColumn , currentRow , fill ) ;
121
+ newImage . setVisiblePixel ( currentColumn , currentRow , fillColor ) ;
122
+ newImage . setVisiblePixel ( currentColumn , currentRow , fillColor ) ;
121
123
}
122
124
}
123
125
}
0 commit comments