A beautiful mathematical visualization that draws a heart shape using the elegant formula: y = x^(2/3) + 0.9·sin(kx)·√(3-x²), animated with increasing values of k to show how mathematical complexity creates beauty.
- Animated Story Sequence: Title fades in, formula appears, then the heart is drawn
- Dynamic Parameter Animation: The parameter
kincreases from 0 to 100, showing the evolution of the heart curve - Mathematical Formula Display: Beautiful rendering of the equation with proper mathematical notation
- Real-time Graph Plotting: Watch the heart being drawn point by point
- Cross-platform: Runs on Windows, macOS, and Linux
The heart curve is defined by the equation:
y = x^(2/3) + 0.9·sin(kx)·√(3-x²)
Where:
x^(2/3)creates the basic heart shape0.9·sin(kx)·√(3-x²)adds the wavy, fluttering effect that increases withk- The domain is limited to
|x| ≤ √3 ≈ 1.732
- Rust (2021 edition or later) - Install from rustup.rs
# Clone the repository
git clone <repository-url>
cd valentine
# Build and run
cargo run --releaseSimply run the program and enjoy the animation!
cargo run --release- ESC - Exit the application
You can customize the animation by modifying these constants in src/main.rs:
const ANIMATION_SPEED: f32 = 1.0; // Speed multiplier for the animation
const MAX_K: f32 = 100.0; // Maximum value of k parameter
const GRAPH_SCALE: f32 = 120.0; // Scale factor for the graph display- macroquad (0.4.14) - Simple and easy-to-use 2D game engine for Rust
- plotters (0.3) - Chart drawing library (with bitmap encoder support)
- plotters-bitmap (0.3) - Bitmap rendering support
- minifb (0.25) - Cross-platform window creation
- gif (0.14.1) - GIF encoding/decoding
- image (0.25.9) - Image processing library
valentine/
├── src/
│ └── main.rs # Main application code
├── Cargo.toml # Project configuration and dependencies
├── Cargo.lock # Dependency lock file
└── README.md # This file
- Intro Title: "Happy Valentine" fades in at center
- Move Title: Title smoothly transitions to top of screen
- Formula Intro: Mathematical formula appears at center
- Move Formula: Formula moves to bottom of screen
- Graphing: Heart curve is drawn with increasing
kvalue - Finale: Final heart shape with
k = 100.00
- Window: 800×800 pixels with high DPI support
- Frame Rate: Vsync synchronized
- Rendering: Real-time line-by-line plotting using macroquad's drawing functions
- Mathematical Precision: Domain boundaries enforced at
|x| ≤ √3
This project is open source and available under the MIT License.
Created as a Valentine's Day gift to show that mathematics can express even the most beautiful things in life.
"Mathematics is the language with which God has written the universe." - Galileo Galilei