Source code for the Path animator framework on the project page.
Just load the inbrowser/webroot/inde.html and go on. Completely client side, no server nor internet needed.
This algorithm uses a simple distance calculation based from one or more start points.
- The start points are added to the "to process" queue.
- The distance values on all pixels are set to max distance on start.
- Main loop
- Each point in the "to process" queue is taken and it's value (distance).
- Each surrounding pixel takes the last distance (the center) and adds the distance given by the parameters m_weighBlock and m_weightPath
The input image selects the weight from the two parameters, a 0 (black) pixel takes 100% of the block value, a (255) white pixel
is 100% path weight.
- If this distance is smaller than the previous pixel that was calulated, replace it and add the pixel to the next list of pixel to be processed.
- After the iteration is done, clear the process queue and swap with the next queue and repeat until the next queue is empty or the hard limit of 10.000 iterations is met.
- Postprocessing (C++ version)
- After the raw distances are calculated, the actual max distance is found.
- The raw map (floating ponts) is mapped down to a 16 bit image and the distance is saved in the red channel.
- the iteration where the pixel was set is in the green channel
- the blue channel is a mask if the pixel was seen as a path (65535) or as a block (0).
The threshold value sets the point where a path becomes a block.
Setting the threshold allows some cheating. You can add an path between areas with a gray value, the algorithm uses it to calculate
- Similar to the C++ version, due to lack of 16 bit image support the higher bits are mapped to the red channel, the lower bits to the green channel.
- No iterations are exported