File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 7777 < th > HWB</ th >
7878 < td > </ td >
7979 </ tr >
80+ < tr id ="colorfunc ">
81+ < th > color()</ th >
82+ < td > </ td >
83+ </ tr >
8084 </ tbody >
8185 </ table >
8286
144148 cell . textContent = `rgb(${ R } ${ G } ${ B } / ${ opacity } )` ;
145149 }
146150 createHSL ( R , G , B , opacity ) ;
151+ createColorFunc ( R , G , B , opacity ) ;
152+ }
153+
154+ function createColorFunc ( r , g , b , opacity ) {
155+ const cell = document . querySelector ( "#colorfunc td" ) ;
156+ const R = Number ( ( r / 255 ) . toFixed ( 2 ) ) ;
157+ const G = Number ( ( g / 255 ) . toFixed ( 2 ) ) ;
158+ const B = Number ( ( b / 255 ) . toFixed ( 2 ) ) ;
159+ if ( opacity === 1 ) {
160+ cell . textContent = `color(srgb ${ R } ${ G } ${ B } )` ;
161+ } else {
162+ cell . textContent = `color(srgb ${ R } ${ G } ${ B } / ${ opacity } )` ;
163+ }
147164 }
148165
149166 function createHSL ( r , g , b , opacity ) {
You can’t perform that action at this time.
0 commit comments