Skip to main content
๐ŸŒ Public

Share visualization

Send this visualization to others.

Fork of Making a Smiley Face Tweaked

Public visualization

Fork of Making a Smiley Face Tweaked

0 stars0๐ŸŒ Public
XXizhiWu211
Last edited Jan 10, 2022
Created on Jan 10, 2022

This interactive example displays a smiley face drawn using the SVG markup language with React. The code imports the `d3` library and uses the `arc()` function to create the curved mouth path. The face consists of concentric circles for the head and eyes, with dimensions and positions calculated using JavaScript variables for precise placement. The SVG uses explicit width and height attributes of 960 by 500 pixels, and the design demonstrates how mathematical computations can control graphical elements in a JavaScript-powered web environment.

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

Comments

Sign in to join the discussion.

MIT Licensed