Check out this blog post I wrote about this project!
Note that this project utilizes the RMagick gem, which has some pre-requisites. Please follow the instructions in RMagick's README to get these setup. This project currently uses RMagick version 4.2.
Once the prerequisites are taken care of, run bundle install in your terminal to install the required gems.
This project uses the Thor gem to implement a command line interface. In the CLI, you can use bin/run to see a list of available commands.
If
bin/runis not working, try usingruby bin/runinstead.
$ bin/run
Commands:
run help [COMMAND] # Describe available commands or one specific command
run render_gif # Render a GIFTo get more info on a command, use help and you should get a longer description of the command as well as a list of all of its options.
$ bin/run help render_gifTo actually run the scripts, use this command:
$ bin/run render_gifThere are a number of options for running this command as well, and they can be overwritten like so:
$ bin/run render_gif --subfolder=demo --columns=32 --rows=10 --bg_color=chocolate --fg_color="mint cream" --fps=10 --dot_size=10 --hold_time=0.5 --transition_time=3Any of the options can be left out to use the default. To see the default values, run the help command and it will display a list of options, what each option's purpose is, and the default value.
The option defaults are saved in the ./config/defaults.rb file. If an option is not specified when the program is executed, this is where it will pull values from. Any of these can be changed if you have you're own preferred defaults.
In addition, the formula on how to calculate a dot's size based on the pixel's relative luminance is defined here. It uses a lambda function so it can be passed into the class where the calculations are performed. While this isn't able to be overwritten from the command line, it is brought into the defaults.rb file to make it easier to access. Here is the default formula:
DOT_SIZE_FORMULA = -> (lum) { (1 - lum) ** 2 }In the repo there's a folder, ./assets/demo, that has some sample images. These images act as the keyframes in the animation:
After running bin/run render_gif --subfolder=demo, you should see something like this added to the ./output folder:
For a list of acceptable color names for the bg_color and fg_color options, take a look at this page in RMagick's documentation.


