File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 118
118
if ( opacity === 1 ) {
119
119
cell . textContent = color ;
120
120
} else {
121
- cell . textContent = ` ${ color } ${ hexOpacity ( opacity ) } ` ;
121
+ cell . textContent = hexOpacity ( color , opacity ) ;
122
122
}
123
123
}
124
124
187
187
function setBackgroundColor ( color , opacity ) {
188
188
const body = document . querySelector ( "div" ) ;
189
189
if ( opacity !== 1 ) {
190
- color = color + "" + hexOpacity ( opacity ) ;
190
+ color = hexOpacity ( color , opacity ) ;
191
191
}
192
192
body . style . backgroundColor = color ;
193
193
opacityPicker . style . accentColor = color ;
194
194
colorPicker . style . accentColor = color ;
195
195
}
196
196
197
- function hexOpacity ( opacity ) {
197
+ function hexOpacity ( color , opacity ) {
198
+ let char = "00"
198
199
if ( opacity > 0 ) {
199
- return Math . floor ( opacity * 255 ) . toString ( 16 ) ;
200
- } else {
201
- return "00" ;
200
+ char = Math . floor ( opacity * 255 ) . toString ( 16 ) ;
202
201
}
202
+ return `${ color } ${ char } `
203
203
}
204
204
</ script >
205
205
</ body >
You can’t perform that action at this time.
0 commit comments