Puzzle generator
This is a PHP library intended to render Rubik's cube puzzles as SVG images. The idea is to do this by navigating to https://puzzle-generator.robiningelbrecht.be/cube and provide query parameters to configure the desired cube.
It's heavily inspired by visualcube and
PuzzleGen. Thanks to tdecker91
for providing these!
Examples
Default
https://puzzle-generator.robiningelbrecht.be/cube
Scrambled
https://puzzle-generator.robiningelbrecht.be/cube?cube[algorithm]=M2 E2 S2
Cube size
https://puzzle-generator.robiningelbrecht.be/cube?cube[size]=6
Rotations
https://puzzle-generator.robiningelbrecht.be/cube?rotations[0][axis]=y&rotations[0][value]=120&rotations[1][axis]=x&rotations[1][value]=120
Color scheme
https://puzzle-generator.robiningelbrecht.be/cube?cube[colorScheme][U]=EFFF01&cube[colorScheme][R]=047F01
Mask
https://puzzle-generator.robiningelbrecht.be/cube?cube[mask]=lastLayerEdges
Case
https://puzzle-generator.robiningelbrecht.be/cube?cube[case]=F U' F' U2 F U R U' R' U' F'
View from top
https://puzzle-generator.robiningelbrecht.be/cube?view=top
View as net
https://puzzle-generator.robiningelbrecht.be/cube?view=net
Combination
https://puzzle-generator.robiningelbrecht.be/cube?size=250&backgroundColor=cccccc&cube[size]=4&cube[algorithm]=R U D2
Documentation
Param | Default | Valid range | Description |
---|---|---|---|
size | 128 | 1 - 1024 | The width and the height of the SVG container |
backgroundColor | transparent | HTML hex color codes (ex. #FFFFFF ) or transparent |
The background color of the SVG container |
rotations |
|
x | y | z with any valid degree |
The angle the puzzle is viewed at can be adjusted by passing in rotations. They are a list of angle rotations to perform on the puzzle before rendering. They can be adjusted to get the perfect view of the puzzle for your purposes. |
view | 3D |
3D | top | net |
The view in which the cube will be rendered. Using top or net will override any custom viewport rotations passed in. |
cube[size] | 3 | 1 - 10 | Value n represent an NxNxN cube |
cube[colorScheme] |
|
HTML hex color codes (ex. #FFFFFF ) |
Any color can be used, but each color has to be unique. |
cube[baseColor] | #000000 |
HTML hex color codes (ex. #FFFFFF ) |
Base color of the cube. In other words the lines between the stickers. |
cube[mask] |
firstLayer | F2L | lastLayer |
lastLayerCorners | lastLayerEdges | OLL
|
Mask will gray out certain stickers of the puzzle to highlight the remaining stickers. Stickers are grayed out before algorithms are applied so we can see the effect of the algorithm. | |
cube[algorithm] | ([2-9]+)?([UuFfRrDdLlBbMESxyz])(w)?(\d+\\'|\\'\d+|\d+|\\')? |
WCA cube notation. The rendered image will show the state of the puzzle after the algorithm has been applied. | |
cube[case] | ([2-9]+)?([UuFfRrDdLlBbMESxyz])(w)?(\d+\\'|\\'\d+|\d+|\\')? |
Case is the opposite of an algorithm. It reverses the algorithm and then applies it to the puzzle. This is helpful to show the state of the puzzle before an algorithm is applied. This cannot be combined with algorithm |
Development
Feel free to fork and make changes to your needs. Consider giving it a ⭐ when you do.
Clone repository
> git clone [email protected]:robiningelbrecht/puzzle-generator.git
Build Docker containers
> docker-compose up --build -d
Install dependencies
> docker-compose run --rm php-cli composer install
Navigate to http://localhost:9090