Skip to content

kagesyntax/Heartmath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

💖 Math of Love - Valentine's Heart Animation

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.

Rust License Platform

✨ Features

  • Animated Story Sequence: Title fades in, formula appears, then the heart is drawn
  • Dynamic Parameter Animation: The parameter k increases 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 Mathematics

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 shape
  • 0.9·sin(kx)·√(3-x²) adds the wavy, fluttering effect that increases with k
  • The domain is limited to |x| ≤ √3 ≈ 1.732

🚀 Installation

Prerequisites

  • Rust (2021 edition or later) - Install from rustup.rs

Building from Source

# Clone the repository
git clone <repository-url>
cd valentine

# Build and run
cargo run --release

🎮 Usage

Simply run the program and enjoy the animation!

cargo run --release

Controls

  • ESC - Exit the application

🛠️ Configuration

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

📦 Dependencies

  • 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

🏗️ Project Structure

valentine/
├── src/
│   └── main.rs          # Main application code
├── Cargo.toml           # Project configuration and dependencies
├── Cargo.lock           # Dependency lock file
└── README.md            # This file

🎨 Animation Sequence

  1. Intro Title: "Happy Valentine" fades in at center
  2. Move Title: Title smoothly transitions to top of screen
  3. Formula Intro: Mathematical formula appears at center
  4. Move Formula: Formula moves to bottom of screen
  5. Graphing: Heart curve is drawn with increasing k value
  6. Finale: Final heart shape with k = 100.00

🔧 Technical Details

  • 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

📝 License

This project is open source and available under the MIT License.

💝 Made with Love

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

About

A mathematically precise, beautiful heart animation renderer built with Rust and Dioxus.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages