20. Ellipse

Track the shape of an ellipse.

Step I: Setup

  • The background is 400x300.
  • There are blue circles centered at (50,150) and (350,150).
  • The model is a posn.
  • A purple circle follows your mouse.

Step II: Colors

This description will use two variables:

  • dA: the distance from the model to the center of the left circle
  • dB: the distance from the model to the center of the right circle

Measure the sum of the distances (dA+dB). If that number is less than 360, use a purple circle, but otherwise use an orange circle.

Example

Adding the lines and the good colors are optional. The ellipse shown below is made with build-image, but you could use a 360x200 ellipse.

Last modified January 31, 2025: Ellipse color changing code. (225cc7f)