Skip to main content
100%

United States of Voronoi Tweening

✓ Published0🌍 Public
Aalexmacy
Last edited Aug 24, 2016
Created on Aug 24, 2016

This visualization animates a tween between the geographic outlines of US states and their Voronoi cell boundaries, generated from state capitals via d3.voronoi. The map uses a Mercator projection and toggles between each state's projected border and its Voronoi polygon every two seconds, with a custom shape interpolation function that redistributes points equally along each side of the destination shape to avoid rounded or skipped corners. A clip path confines the animation to the state boundaries, and capital cities are marked with small circles. The transition is built with d3.v4 SVG elements and includes a reusable shapeTween.js module with two tweening approaches, one based on side-length distribution and another on proportional path length.

AI-generated description

This is another version of the shape tweening from <a href='http://bl.ocks.org/alexmacy/06cf037853999219cd82bc79edc4aee6'>this block.</a> Inspired by Jason Davies' <a href="https://www.jasondavies.com/maps/voronoi/us-capitals/">United States of Voronoi.</a>

The transition I had previously used for shape tweening plots the points along the new shape proportionally to where they were along the original shape. This potentially results in rounded or skipped corners, so I had to figure out a new way to do it.

The new transition used here draws the destination shapes by plotting the points form the old shape equally along each side of the new shape. The result isn't always as clean of a transition, but it's still pretty smooth and the resulting shape is free from any rounded or skipped corners.

I also put both transition functions in the standalone file 'shapeTween.js' to be able to easily reuse it later.

gpl-3.0 Licensed

Similar vizzes