Loop Face

Dynamic Drawing of Facial Features

This is a demo named "Loop-Face" designed to dynamically draw facial features (eyes and mouth) on an HTML canvas. This code functions as a demo that animates the movement of the mouth and eyes on the canvas, changing facial expressions.

The overview of the code is as follows:

  1. The initialize function takes an HTMLCanvasElement, obtains the 2D context, and moves the drawing origin to the center of the canvas. It initializes Loop objects representing the mouth and the right eye and uses animation frames to achieve the motion.
  2. The step function is executed for each frame of the animation, updating the positions of the mouth and eyes based on the elapsed time, and resetting their positions at random intervals. It also draws black circles at the eye positions to represent pupils.
  3. The Loop class manages shapes based on given points and radii, with methods to update the current and next positions of each point. The setPositions method repositions points randomly, and the update method gradually moves current points toward the next points.
  4. The drawCurve function is a helper function that connects points with smooth curves and draws them.