(colorClasses, mode, scaleType)
| 135 | } |
| 136 | |
| 137 | function createColorData(colorClasses, mode, scaleType) { |
| 138 | const f = getChannelsAndFunction(mode); |
| 139 | const method = (d) => chroma(d)[f.func](); |
| 140 | |
| 141 | let dataArray = []; |
| 142 | |
| 143 | for (let i = 0; i < colorClasses.length; i++) { |
| 144 | let currentColor = !scaleType || scaleType === 'theme' ? colorClasses[i].backgroundColorScale : colorClasses[i].colors; |
| 145 | |
| 146 | let dataA = currentColor.map(function (d) { |
| 147 | let channelValue = method(d)[f.c1]; |
| 148 | // Need to do some geometry for polar colorspaces |
| 149 | if (mode === 'CAM02p' || mode === 'LCH' || mode === 'HSL' || mode === 'HSV' || mode === 'HSLuv' || mode === 'OKLCH') { |
| 150 | let s = mode === 'HSL' || mode === 'HSV' ? method(d)[f.c2] * 100 : mode === 'OKLCH' ? method(d)[f.c2] * 310 : method(d)[f.c2]; |
| 151 | let h = channelValue; |
| 152 | return filterNaN(convertToCartesian(s, h).x); |
| 153 | } |
| 154 | if (mode === 'OKLAB') return filterNaN(channelValue * 460); |
| 155 | else return filterNaN(channelValue); |
| 156 | }); |
| 157 | let dataB = currentColor.map(function (d) { |
| 158 | let channelValue = method(d)[f.c3]; |
| 159 | if (mode === 'HSL' || mode === 'HSV' || mode === 'OKLCH' || mode === 'OKLAB') channelValue = channelValue * 100; |
| 160 | return filterNaN(channelValue); |
| 161 | }); |
| 162 | let dataC = currentColor.map(function (d) { |
| 163 | let channelValue = method(d)[f.c2]; |
| 164 | // Need to do some geometry for polar colorspaces |
| 165 | if (mode === 'CAM02p' || mode === 'LCH' || mode === 'HSL' || mode === 'HSV' || mode === 'HSLuv' || mode === 'OKLCH') { |
| 166 | let s = mode === 'HSL' || mode === 'HSV' ? channelValue * 100 : mode === 'OKLCH' ? channelValue * 310 : channelValue; |
| 167 | let h = method(d)[f.c1]; |
| 168 | return filterNaN(convertToCartesian(s, h).y); |
| 169 | } |
| 170 | if (mode === 'OKLAB') return filterNaN(channelValue * 460); |
| 171 | return filterNaN(channelValue); |
| 172 | }); |
| 173 | |
| 174 | let dataObj = { |
| 175 | type: 'scatter3d', |
| 176 | mode: 'lines', |
| 177 | x: dataA, |
| 178 | y: dataC, |
| 179 | z: dataB, |
| 180 | name: colorClasses[i].name, |
| 181 | opacity: 1, |
| 182 | markercolor: 'red', |
| 183 | line: { |
| 184 | width: 16, |
| 185 | color: currentColor |
| 186 | } |
| 187 | }; |
| 188 | |
| 189 | dataArray.push(dataObj); |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * Generate hidden scatterplot points at the min/max |
| 194 | * positions of the color space's gamut. Then merge that |
no test coverage detected