Skip to main content
100%

Smiley Face Tutorial

✓ Published0🌍 Public
RRochisman Datta
Last edited Sep 25, 2021
Created on Sep 25, 2021

This example shows how to construct a simple smiley face using SVG elements. The face is composed of a yellow circle, two black eye circles, and a mouth drawn as a curved path. The code relies on the D3 library's `arc` helper from the `d3-shape` package to generate the mouth's arc, using method chaining to set its inner and outer radii and start and end angles. The implementation exists in two versions: one using D3's imperative selection and appending methods on an SVG element, and another using React with JSX to declaratively render the same shapes, both demonstrating SVG group elements and template literals.

AI-generated description

Part-3) D3 intro

  • Getting started with the D3 library

  • Using arc from the d3-shape package arc is a helper function used for drawing an arc shape for the mouth.

  • SVG path elements

  • SVG group elements and the transform attribute

  • Using ES6 Template Literals

  • Adding the mouth to our face

Assignment: Tweak the Face!!

MIT Licensed

Similar vizzes