This is oringinally a program for the Functional Programming Competition and is under refactor
see details about the competition here: Link
see original source here: Link
- 3Blue1Brwon's amazing video told us that Fourier Series can draw anything
- In the form of Integral, the series will approach the oringinal image as the number of terms rise
- The Mathematical Pinciple behind the image is so amazing that I decide to present this simple fun programm that draws anything
- prepare your data in the following json format, where each object of series represents a term of fourier series
{
"series": [
{
"number" : 0,
"real" : 1,
"imag" : 2
}
]
}
number
represents exactly n in the form, which should be a Integer, and controls how fast the vector spinsreal
andimag
represent the complex constant Cn in the form, control the starting position and length of the vector- Then put them in one directory without other files. Each file will be transformed to a closed curve. In order to draw a image with multiple curves, you'll need the same amount of json files.
- this image of haskell logo is generated using data from the
data
directory
- clone the repository and run cabal-build
- make sure to run
cabal update
once if it is newly installed
git clone https://github.com/HE7086/Fourier.git
cd Fourier
cabal build
- you can find the binary inside
dist
folder
short | long | description |
---|---|---|
-g | --gif | generate gif files |
-p | --png | generate png files |
-c | --combined | combine the images afterwards |
-o PATH | --output PATH | specify output path |
-i PATH | --input PATH | specify input path/file |
-v | --version | print version message |
-h | --help | print help message |
- by default help messages will be printed
- generate gifs from all the files in a directory
cabal run -- Fourier --gif --input ./data --output ./out --combined
- generate one png from a file
cabal run -- Fourier --png --input ./data/1.json --output ./out
- run with threaded mode (significantly increase performance on multicore cpus)
cabal run -- Fourier --png --input ./data/1.json --output ./out +RTS -N
- In the file
src/Settings.hs
are several option that can be customized easilywidth
,height
: the height and width of the generated imagewhite
,black
: the standard pixel colorpixelArt
: the function that dertermines color and by default draws blackpointCount
: the number of points to be paintedgifStep
: how many pixels will be rendered each frame- warning : terrible runtime if set too small
filename
: the name of outputed imagescaleFactor
: how much the final image will be scaled
- These customization options will be merged into cli flags in the future
- optimize performance
- adjustable line thickness
- adjustable fore-/background color
- coordinates converter: convert coordinates to forms