Skip to content

Instantly share code, notes, and snippets.

@harking
Forked from anonymous/_.md
Created September 28, 2012 14:31
Show Gist options
  • Save harking/3800197 to your computer and use it in GitHub Desktop.
Save harking/3800197 to your computer and use it in GitHub Desktop.
just another inlet to tributary
{"editor_editor":{"coffee":false,"vim":true,"emacs":false,"width":600,"height":300,"hide":false},"endpoint":"tributary","public":true}
var svg = d3.select("svg");
var defs = svg.append("defs");
function make_gradient(container, id, colors)
{
var gradient = container.append("svg:linearGradient")
.attr("id", id);
for (var x=0, length=colors.length; x<length; x++) {
gradient.append("svg:stop")
.attr("offset", x/(length-1)*100 + "%")
.attr("stop-color", colors[x])
.attr("stop-opacity", 1);
}
return gradient;
}
make_gradient(defs, "grad", ["#FFFFFF", "#5FAF4B"]);
svg.append("rect")
.attr("width", 329+"px")
.attr("height", 20+"px")
.attr("fill", "url(#grad)")
.attr("transform", "translate(100,100)");
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment