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 118118 if ( opacity === 1 ) {
119119 cell . textContent = color ;
120120 } else {
121- cell . textContent = ` ${ color } ${ hexOpacity ( opacity ) } ` ;
121+ cell . textContent = hexOpacity ( color , opacity ) ;
122122 }
123123 }
124124
187187 function setBackgroundColor ( color , opacity ) {
188188 const body = document . querySelector ( "div" ) ;
189189 if ( opacity !== 1 ) {
190- color = color + "" + hexOpacity ( opacity ) ;
190+ color = hexOpacity ( color , opacity ) ;
191191 }
192192 body . style . backgroundColor = color ;
193193 opacityPicker . style . accentColor = color ;
194194 colorPicker . style . accentColor = color ;
195195 }
196196
197- function hexOpacity ( opacity ) {
197+ function hexOpacity ( color , opacity ) {
198+ let char = "00"
198199 if ( opacity > 0 ) {
199- return Math . floor ( opacity * 255 ) . toString ( 16 ) ;
200- } else {
201- return "00" ;
200+ char = Math . floor ( opacity * 255 ) . toString ( 16 ) ;
202201 }
202+ return `${ color } ${ char } `
203203 }
204204 </ script >
205205 </ body >
You can’t perform that action at this time.
0 commit comments