[ Launch: pure svg spinner generator ] 11479754 by chiester
-
-
Save chiester/11479754 to your computer and use it in GitHub Desktop.
pure svg spinner generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"description":"pure svg spinner generator","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"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,"tab":"edit","display_percent":0.5635097493036215,"hidepanel":false,"fullscreen":false,"ajax-caching":true,"thumbnail":"http://i.imgur.com/YIqdG8Q.png"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// tweak these options | |
var lineTotal = 12, | |
lineLength = 30, | |
speed = 1.28, | |
width = 8, | |
radius = 20, | |
color = '#59C00A', | |
// dont touch these | |
posX = 200, | |
posY = 200, | |
svg = d3.select('svg'), | |
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', | |
'attributeType': 'CSS', | |
'from': 1, | |
'to': 0.3, | |
'dur': speed + 's', | |
'begin': function (d,i) { | |
return 16/150 * (i + 1) + 's'; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment