@@ -64,8 +64,8 @@ export function drawRectangle(
64
64
origin = { column : 0 , row : 0 } ,
65
65
width = image . width ,
66
66
height = image . height ,
67
- strokeColor : color = getDefaultColor ( image ) ,
68
- fillColor,
67
+ strokeColor = getDefaultColor ( image ) ,
68
+ fillColor = 'none' ,
69
69
} = options ;
70
70
const { column, row } = origin ;
71
71
@@ -79,35 +79,25 @@ export function drawRectangle(
79
79
newImage = maskToOutputMask ( image , options , { clone : true } ) ;
80
80
}
81
81
82
- if ( color !== 'none' ) {
82
+ if ( strokeColor !== 'none' ) {
83
83
for (
84
84
let currentColumn = column ;
85
85
currentColumn < column + width ;
86
86
currentColumn ++
87
87
) {
88
- newImage . setVisiblePixel ( currentColumn , row , color ) ;
89
- newImage . setVisiblePixel ( currentColumn , row + height - 1 , color ) ;
88
+ newImage . setVisiblePixel ( currentColumn , row , strokeColor ) ;
89
+ newImage . setVisiblePixel ( currentColumn , row + height - 1 , strokeColor ) ;
90
90
}
91
91
for (
92
92
let currentRow = row + 1 ;
93
93
currentRow < row + height - 1 ;
94
94
currentRow ++
95
95
) {
96
- newImage . setVisiblePixel ( column , currentRow , color ) ;
97
- newImage . setVisiblePixel ( column + width - 1 , currentRow , color ) ;
98
-
99
- if ( fillColor ) {
100
- if ( fillColor === 'none' ) continue ;
101
- for ( let col = column + 1 ; col < column + width - 1 ; col ++ ) {
102
- newImage . setVisiblePixel ( col , currentRow , fillColor ) ;
103
- newImage . setVisiblePixel ( col , currentRow , fillColor ) ;
104
- }
105
- }
96
+ newImage . setVisiblePixel ( column , currentRow , strokeColor ) ;
97
+ newImage . setVisiblePixel ( column + width - 1 , currentRow , strokeColor ) ;
106
98
}
107
99
}
108
- // color is none but fill is defined
109
- else if ( fillColor ) {
110
- if ( fillColor === 'none' ) return newImage ;
100
+ if ( fillColor !== 'none' ) {
111
101
for (
112
102
let currentRow = row + 1 ;
113
103
currentRow < row + height - 1 ;
0 commit comments