Skip to main content
100%

Mouse follower

✓ Published1🌍 Public
Ccharles-duron
Last edited Nov 6, 2022
Created on Nov 1, 2022
Forked from Smiley face part I

This example shows a simple smiley face that follows the mouse cursor across a 960-by-500 SVG canvas. The face is drawn with a yellow linear gradient, two elliptical eyes, and a d3.arc-generated mouth, all assembled from React components. As the user moves the mouse, the React state updates the circle’s center coordinates via the `onMouseMove` handler, re-rendering the face at the new position. The code uses React’s `useState` and `useCallback` hooks, along with d3’s `arc` for the mouth path, and renders everything as SVG elements.

AI-generated description

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

See also React Starter.

MIT Licensed

Similar vizzes