MCPcopy Index your code
hub / github.com/davidmerfield/randomColor / setFormat

Function setFormat

randomColor.js:199–241  ·  view source on GitHub ↗
(hsv, options)

Source from the content-addressed store, hash-verified

197 }
198
199 function setFormat(hsv, options) {
200 switch (options.format) {
201 case "hsvArray":
202 return hsv;
203
204 case "hslArray":
205 return HSVtoHSL(hsv);
206
207 case "hsl":
208 var hsl = HSVtoHSL(hsv);
209 return "hsl(" + hsl[0] + ", " + hsl[1] + "%, " + hsl[2] + "%)";
210
211 case "hsla":
212 var hslColor = HSVtoHSL(hsv);
213 var alpha = options.alpha || Math.random();
214 return (
215 "hsla(" +
216 hslColor[0] +
217 ", " +
218 hslColor[1] +
219 "%, " +
220 hslColor[2] +
221 "%, " +
222 alpha +
223 ")"
224 );
225
226 case "rgbArray":
227 return HSVtoRGB(hsv);
228
229 case "rgb":
230 var rgb = HSVtoRGB(hsv);
231 return "rgb(" + rgb.join(", ") + ")";
232
233 case "rgba":
234 var rgbColor = HSVtoRGB(hsv);
235 var alpha = options.alpha || Math.random();
236 return "rgba(" + rgbColor.join(", ") + ", " + alpha + ")";
237
238 default:
239 return HSVtoHex(hsv);
240 }
241 }
242
243 function getMinimumBrightness(H, S) {
244 var lowerBounds = getColorInfo(H).lowerBounds;

Callers 1

randomColorFunction · 0.85

Calls 3

HSVtoHSLFunction · 0.85
HSVtoRGBFunction · 0.85
HSVtoHexFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…