Skip to content

Instantly share code, notes, and snippets.

@k-izzo
Created March 14, 2014 20:41
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 k-izzo/9556377 to your computer and use it in GitHub Desktop.
Save k-izzo/9556377 to your computer and use it in GitHub Desktop.
interval
{"description":"interval","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.coffee":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true,"thumbnail":"http://i.imgur.com/fbcecz9.png"}
svg = d3.select('svg').append('g')
.attr('transform', 'translate(' + [30,30] + ')')
svg.append('circle')
.attr({
cx: 10
cy: 10
r: 18
fill: 'green'
})
change_color = ->
svg.select('circle')
.transition().duration(500)
.attr({
cx: 30
fill: 'red'
})
.transition().delay(500).duration(500)
.attr({
cx: 10
fill: 'blue'
})
i = 0
k = ->
if i < 5
i += 1
console.log 'change #' + i
change_color()
else
clearInterval(cycle)
cycle = setInterval(k, 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment