MCPcopy
hub / github.com/VincentGarreau/particles.js / hexToRgb

Function hexToRgb

particles.js:1449–1462  ·  view source on GitHub ↗
(hex)

Source from the content-addressed store, hash-verified

1447} )();
1448
1449function hexToRgb(hex){
1450 // By Tim Down - http://stackoverflow.com/a/5624139/3493650
1451 // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
1452 var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
1453 hex = hex.replace(shorthandRegex, function(m, r, g, b) {
1454 return r + r + g + g + b + b;
1455 });
1456 var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
1457 return result ? {
1458 r: parseInt(result[1], 16),
1459 g: parseInt(result[2], 16),
1460 b: parseInt(result[3], 16)
1461 } : null;
1462};
1463
1464function clamp(number, min, max) {
1465 return Math.min(Math.max(number, min), max);

Callers 1

pJSFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…