Skip to main content
100%

Rounded Rectangles

✓ Published0🌍 Public
Mmbostock
Last edited Feb 9, 2016
Created on Aug 3, 2011

A grid of 25 rounded rectangles animates toward the mouse position while continuously rotating, with each rectangle’s fill color drawn from a categorical scale. Driven by a d3.timer, each tick updates the rectangles’ center coordinates and rotation angle based on their distance to the cursor. The SVG shapes use `rx` and `ry` attributes, and the code leverages D3’s data binding, `d3.scale.category20c`, and a `mousemove` event to track the pointer. This example adapts a Paper.js demo into D3 with animated transforms.

AI-generated description

Inspired by this Paper.js example, this demonstrates animated rounded rectangles (svg:rect elements with "rx" and "ry" attributes). The data associated with each rectangle is its center position and rotation angle in degrees. Each tick of the animation, the rectangles drift towards the mouse location and rotate slightly. Built with D3.js using SVG.

gpl-3.0 Licensed

Similar vizzes