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 77
77
< th > HWB</ th >
78
78
< td > </ td >
79
79
</ tr >
80
+ < tr id ="colorfunc ">
81
+ < th > color()</ th >
82
+ < td > </ td >
83
+ </ tr >
80
84
</ tbody >
81
85
</ table >
82
86
144
148
cell . textContent = `rgb(${ R } ${ G } ${ B } / ${ opacity } )` ;
145
149
}
146
150
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
+ }
147
164
}
148
165
149
166
function createHSL ( r , g , b , opacity ) {
You can’t perform that action at this time.
0 commit comments