Skip to content

Instantly share code, notes, and snippets.

@enthal
Last active November 14, 2020 02:55
Show Gist options
  • Select an option

  • Save enthal/3a7e4923c274cb678f60 to your computer and use it in GitHub Desktop.

Select an option

Save enthal/3a7e4923c274cb678f60 to your computer and use it in GitHub Desktop.
D3/SVG "finger" articulation: https://bl.ocks.org/enthal/3a7e4923c274cb678f60
<!DOCTYPE html>
<meta charset="utf-8">
<style>
svg {
fill: none;
stroke: #000;
stroke-width: 4px;
}
</style>
<body></body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js" charset="utf-8"></script>
<script>
var width = 960, height = 500;
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
var g0 = svg.append("g")
.attr("transform", "translate(100,200)")
.append("g");
g0.append("line")
.attr("x2", 200);
g0
.transition()
.duration(1000)
.ease("ease-in")
.attr("transform", "rotate(-25)")
.transition()
.duration(600)
.ease("linear")
.attr("transform", "rotate(-22)")
.transition()
.duration(600)
.ease("ease-out")
.attr("transform", "rotate(-10)");
g1 = g0.append("g")
.attr("transform", "translate(200)")
.append("g")
.attr("transform", "rotate(-15)");
g1.append("line")
.attr("x2", 100);
g1.append("line")
.attr("x2", 150)
.attr("transform", "rotate(-15)");
g1
.transition()
.duration(900)
.ease("ease-out")
.attr("transform", "rotate(50)")
.transition()
.attr("transform", "rotate(20)");
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment