Skip to main content
100%

Making a Smiley Face Tweaked

✓ Published2🌍 Public
Jjjacobatandover
Last edited Jul 4, 2021
Created on Jul 4, 2021

This example shows a stylized smiley face built with scalable vector graphics, featuring a yellow circle for the head, two eyes, a nose, green ears, and a curved mouth. The visualization demonstrates how to combine React with D3 to create shapes that are difficult to express in raw SVG. The code uses JSX to define the SVG structure, while the `arc()` function from the `d3` library generates the smile’s path, taking inner radius, outer radius, and start/end angles as parameters. All elements are positioned relative to a central transform, with constants controlling offsets and dimensions.

AI-generated description

A bare minimum HTML page demonstrating use of CSS and JavaScript.

See also React Starter.

Half way towards a smiley face -- we used CSS to make the margins and the colors.

We used SVG to make the circles.

Feeling frustrated that we couldn't use math to define the DOM structure and use JSX to write HTML in JS and math from JS

Using React, we used JSX to allow us to include HTML in JS

In order to get the smile, we need to use an arc feature, but there's no such element in SVG. So we need to use D3.

We can use d3-shape to get the arc

MIT Licensed

Similar vizzes