Making OLL and PLL visualizations using VisualCube and Python
VisualCube (Source) is a PHP script that allows you to make visualizations for the Rubik's Cube for demonstration purposes. Well-known speedcubing guides use this tool. I wanted to download all OLL and PLL cases in SVG and PNG formats for my PLL recognition guide. Here's how I did it using few short Python and JavaScript scripts.
VisualCube allows you to create several types of visuals- changing transparency, masking pieces that are not related to a specific step in CFOP, tweaking the angle of the cube, etc. All these variables can be specified using URL parameters. For PLL, the URL I wanted was:
http://cube.rider.biz/visualcube.php?fmt=svg&pzl=3&view=plan&case=<algorithm>
The parameters work like this:
fmt
: Specify the type of image extension.pzl
: Specify the puzzle type (e.g. 3 for 3x3, 4 for 4x4, etc).view
: Specify special view for the image.plan
rotates the cube to expose the U face which is what we want for PLL.case
: Specify the alg which solves a specific case.
The first 3 parts of the URL are static. What I want is a list of all PLL algorithms and use them one by one to form a URL and then download the page to my local disk.
For the algorithms, I visited AlgDb.net's PLL page, opened the developer console (CTRL+Shift+I), and ran this JavaScript code in Firefox's multi-line editor mode in the Console:
This outputs a nicely formatted Python dictionary with all PLL names as keys and associated algorithms as values in the console which can be copied and pasted to a Python script.
Similarly, for OLLs, I visited AlgDb's OLL page and ran this code in the console:
The following Python script iterates through these dicts to get the images and saves them locally as <oll_number>.svg and <pll_name>.svg respectively in separate directories. Notice the oll_url
has an additional parameter called stage
equal to oll
so that irrelevant stickers are masked from being coloured and makes the result clearer. Just replace the occurences of svg
in the file to png
and run the script again to get all images as PNG files.
Make sure to run this from an empty directory. Note that these algorithms may not be the best ones in terms of fingertricks and efficiency. In some algs, y/y'/y2 moves have been added at the beginning in order to output images at an angle in which I apply certain algs.
#
PLL cases with arrowsWith VisualCube, it is also possible to make arrows for PLL cases. Additional parameters required for this are:
ac
: Default Arrow Colorarw
: Comma separated list of arrows to draw. Add-s[0-9]
at the end to adjust the length of arrows. Check the following script to see how this works.