A simple JavaFX application that shows the implementation of a closed (and animated) Bézier curve.
I wrote this application because I needed to create a closed path with smoothly changing gradients. The Bézier curves change smoothly but are open, so I had to make some adjustments to make their ends link seamlessly.
The trick of perfectly linking two Bézier curves is to make sure that:
- the end point of the first curve is the same of the start point of the second one (shown in yellow in the figure below);
- the line connecting the last control point of the first line and the first control point of the second one passes through the common point of the two curves (the control points and the lines are shown in grey in the figure below).
Bézier curves at Wikipedia.org
- Java 13 (but can be run since Java 11)
- Maven
mvn compile
mvn javafx:run
- Configurable parameters
- Some comments in the code...