MCPcopy Create free account
hub / github.com/Inviz/lsd / addColor

Function addColor

Source/ART/ART.SVG.js:125–132  ·  view source on GitHub ↗
(offset, color)

Source from the content-addressed store, hash-verified

123 this[type + 'Gradient'] = gradient;
124
125 var addColor = function(offset, color){
126 color = Color.detach(color);
127 var stop = createElement('stop');
128 stop.setAttribute('offset', offset);
129 stop.setAttribute('stop-color', color[0]);
130 stop.setAttribute('stop-opacity', color[1]);
131 gradient.appendChild(stop);
132 };
133 // Enumerate stops, assumes offsets are enumerated in order
134 // TODO: Sort. Chrome doesn't always enumerate in expected order but requires stops to be specified in order.
135 if ('length' in stops) for (var i = 0, l = stops.length - 1; i <= l; i++) addColor(i / l, stops[i]);

Callers 1

ART.SVG.jsFile · 0.85

Calls 1

createElementFunction · 0.85

Tested by

no test coverage detected