heatPlot is a Go tool for generating animated heatmaps (GIFs) from mathematical functions. It parses mathematical expressions involving variables x, y, and t (time), and renders them as a heatmap.
Ensure you have Go installed (Go 1.22+ recommended).
Clone the repository and install the dependencies:
git clone https://bitbucket.org/arran4/heatplot.git
cd heatplot
go mod tidyThere are three main commands available in the cmd directory:
Generates a heatmap GIF from a provided mathematical formula.
Build:
go build -o heatPlot cmd/heatPlot/main.goRun:
./heatPlot [flags] "formula"Flags:
-hcc: Heat colour count (default 126).-speed: Duration between frames (default 100ms).-pointSize: Scale of x/y steps (default 0.1).-scale: Magnification (default 2).-tlb: Time lower bound (start T, default 0).-tub: Time upper bound (end T, default 100).-size: Cartesian plane size (default 100, i.e., -100 to 100).-outputFile: Output filename (default "./out.gif").-footerText: Footer text (default "http://github.com/arran4/").
Example:
./heatPlot -outputFile="example.gif" "y = x * sin(t/10)"Generates random functions and renders one that meets certain "interestingness" criteria (complexity, movement).
Build:
go build -o heatPlotRandom cmd/heatPlotRandom/main.goRun:
./heatPlotRandom [flags]Flags:
Similar to heatPlot, with additional criteria for random generation.
Lists all available single and double parameter functions supported by the parser.
Build:
go build -o whatFunctions cmd/whatFunctions/main.goRun:
./whatFunctionsThe parser supports:
- Variables:
x,y,t - Constants: Numbers
- Operators:
+,-,*,/,%(modulus),^(power) - Functions:
sin,cos,tan,abs,max,min,pow, etc. (SeewhatFunctionsfor full list) - Grouping:
()
The parser generally expects an equation, often in the form LHS = RHS. The heatmap value is calculated as RHS - LHS.
y = x * sin(t/10)
y = x * sin(t/10) + y * cos(t/10)
y = sin(sqrt(x^2 + y^2) - t/5)
y = sin(x/10) + cos(y/10) * sin(t/10)
- Go 1.22 or later
- Make
To regenerate the parser from calc.y:
make setup
make yaccRun the tests:
go test ./...


