Skip to main content
100%

Fork of Shapes and Colors with SVG and CSS

✓ Published0🌍 Public
Rrjohnson5016
Last edited Dec 31, 2020
Created on Dec 31, 2020

This example shows a yellow smiley face drawn with SVG shapes—circles for the eyes, rectangles for the eyebrows, and an arc-based path for the mouth—that animates through D3 transitions. The code uses d3 v5’s `select` and `append` methods to build the SVG hierarchy, with `transition()` and `attr` chaining to sequentially move the eyebrows and morph the mouth’s inner radius. The face is centered via a translation on a group element, and the mouth path relies on `d3.arc()` with changing `innerRadius` values. Styling is applied through CSS, while the animation logic is driven entirely by D3’s transition API.

AI-generated description

An example including some commonly used features of SVG.

MIT Licensed

Similar vizzes