MCPcopy Index your code
hub / github.com/idank/explainshell / d3_rgb_parse

Function d3_rgb_parse

explainshell/web/static/js/d3.v3.js:1402–1438  ·  view source on GitHub ↗
(format, rgb, hsl)

Source from the content-addressed store, hash-verified

1400 return v < 16 ? "0" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16);
1401 }
1402 function d3_rgb_parse(format, rgb, hsl) {
1403 var r = 0, g = 0, b = 0, m1, m2, name;
1404 m1 = /([a-z]+)\((.*)\)/i.exec(format);
1405 if (m1) {
1406 m2 = m1[2].split(",");
1407 switch (m1[1]) {
1408 case "hsl":
1409 {
1410 return hsl(parseFloat(m2[0]), parseFloat(m2[1]) / 100, parseFloat(m2[2]) / 100);
1411 }
1412
1413 case "rgb":
1414 {
1415 return rgb(d3_rgb_parseNumber(m2[0]), d3_rgb_parseNumber(m2[1]), d3_rgb_parseNumber(m2[2]));
1416 }
1417 }
1418 }
1419 if (name = d3_rgb_names.get(format)) return rgb(name.r, name.g, name.b);
1420 if (format != null && format.charAt(0) === "#") {
1421 if (format.length === 4) {
1422 r = format.charAt(1);
1423 r += r;
1424 g = format.charAt(2);
1425 g += g;
1426 b = format.charAt(3);
1427 b += b;
1428 } else if (format.length === 7) {
1429 r = format.substring(1, 3);
1430 g = format.substring(3, 5);
1431 b = format.substring(5, 7);
1432 }
1433 r = parseInt(r, 16);
1434 g = parseInt(g, 16);
1435 b = parseInt(b, 16);
1436 }
1437 return rgb(r, g, b);
1438 }
1439 function d3_rgb_hsl(r, g, b) {
1440 var min = Math.min(r /= 255, g /= 255, b /= 255), max = Math.max(r, g, b), d = max - min, h, s, l = (max + min) / 2;
1441 if (d) {

Callers 1

d3.v3.jsFile · 0.85

Calls 2

d3_rgb_parseNumberFunction · 0.85
execMethod · 0.45

Tested by

no test coverage detected