Skip to content

Instantly share code, notes, and snippets.

/_.md

Created January 11, 2013 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4513073 to your computer and use it in GitHub Desktop.
Save anonymous/4513073 to your computer and use it in GitHub Desktop.
An inlet to Tributary
{"description":"An inlet to Tributary","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"tab":"edit","display_percent":0.5635097493036215,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"hidepanel":false}
var svg = d3.select('svg'),
lineTotal = 16,
lineLength = 20,
speed = 1.28,
width = 4,
radius = 12,
color = '#333',
posX = 100,
posY = 100,
rotIncrement = Math.floor(360/lineTotal),
group,
lines;
function data() {
return new Array(lineTotal);
}
// <g> only needed for nice display in tributary
group = svg.append('g')
.attr('transform', 'translate(' + [posX, posY] + ')');
lines = group.selectAll('line')
.data(data)
.enter()
.append('line')
.attr({
'fill': 'none',
'stroke-linecap': 'round',
'stroke-width': width,
'x1': radius,
'y1': radius,
'x2': lineLength,
'y2': lineLength,
'stroke': color,
'transform': function (d,i) {
return 'rotate(' + (i + 1) * rotIncrement + ')';
}
})
.append('animate')
.attr({
'attributeName': 'opacity',
'repeatCount': 'indefinite',
'from': 1,
'to': 0.3,
'dur': speed + 's',
'begin': function (d,i) {
return 16/200 * (i + 1) + 's';
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment