mp_puzzle
Perplexing Puzzles
PuzzleAnimation Class Reference

Puzzle animation utility class. More...

#include <PuzzleAnimation.h>

Collaboration diagram for PuzzleAnimation:
[legend]

Public Member Functions

 PuzzleAnimation (std::vector< PuzzleState > const &transitions)
 Constructs an animated puzzle with numeric board. More...
 
 PuzzleAnimation (std::string const &img_path, std::vector< PuzzleState > const &transitions)
 Constructs an animated puzzle with an image board. More...
 
void writeToFile (std::string fname)
 Writes the animation to an SVG or GIF file based on the file extension (.svg/.gif). More...
 

Public Attributes

double width = 200
 width of the svg More...
 
double height = 200
 height of the svg More...
 
double tileSize = std::min(width, height) / 4
 size of each tile More...
 
double stepDuration = 0.3
 duration of each animation step in seconds More...
 
double fps = 12
 frames per second More...
 
std::string bgc = "#808080"
 background color More...
 

Detailed Description

Puzzle animation utility class.

Constructor & Destructor Documentation

◆ PuzzleAnimation() [1/2]

PuzzleAnimation::PuzzleAnimation ( std::vector< PuzzleState > const &  transitions)
inline

Constructs an animated puzzle with numeric board.

Parameters
transitionssame as the results from solveAstar/solveBFS

◆ PuzzleAnimation() [2/2]

PuzzleAnimation::PuzzleAnimation ( std::string const &  img_path,
std::vector< PuzzleState > const &  transitions 
)
inline

Constructs an animated puzzle with an image board.

Parameters
img_pathpath the image used for animation
transitionssame as the results from solveAstar/solveBFS

Member Function Documentation

◆ writeToFile()

void PuzzleAnimation::writeToFile ( std::string  fname)

Writes the animation to an SVG or GIF file based on the file extension (.svg/.gif).

You can use any modern browser, or the SVG VSCode extension to view the SVG. If you want to build a GIF of a puzzle where the base image itself is an animated GIF, you must use the SVG construction. (writeToGifFile() cannot handle GIFs as input)

Parameters
fnamename of the file

Member Data Documentation

◆ bgc

std::string PuzzleAnimation::bgc = "#808080"

background color

◆ fps

double PuzzleAnimation::fps = 12

frames per second

◆ height

double PuzzleAnimation::height = 200

height of the svg

◆ stepDuration

double PuzzleAnimation::stepDuration = 0.3

duration of each animation step in seconds

◆ tileSize

double PuzzleAnimation::tileSize = std::min(width, height) / 4

size of each tile

◆ width

double PuzzleAnimation::width = 200

width of the svg


The documentation for this class was generated from the following files: