Skip to content

A REST API for generating customizable SVG images of Rubik's cubes, allowing dynamic sizing and detailed color specification for each side.

Notifications You must be signed in to change notification settings

Dunamis4tw/rubik-render

Repository files navigation

Rubik-Render

Rubik-Render is a Go-based API service that generates SVG images of Rubik's cubes based on a given configuration. The service allows users to customize the cube's size, view (isometric, flat, or unfolded), and color for each side. This tool supports cubes and cuboids of various dimensions.

                    

Features

  • Multiple views: Generate the Rubik's cube in different views, including:

    • isometric: 3D isometric view.
    • flat: Top-down or side view.
    • unfolded: Flat layout showing all sides of the cube.
  • Customizable size: Create cubes and cuboids with dimensions ranging from 1x1x1 to 64x64x64.

  • Color specification: Customize the colors for each side of the cube using a flexible notation.

API Endpoints

Request

GET v1/{puzzle}/{view}/{size}/{colors}

  • puzzle: Specifies the type of puzzle. Options: cube, skewb, pyramid (coming soon).

  • view: The display view for the cube. Options: isometric, flat, unfolded.

  • size:

    • For isometric,unfolded: Cube or cuboid dimensions in the format {x}x{y}x{z}.
    • For flat: Dimensions should be provided in the format {x}x{y}, as it only represents the top and adjacent sides of the cube.
  • colors:

    • For isometric: Colors should be provided in the format {left}-{up}-{right}-{base}.
    • For flat: Colors should be provided in the format {front}-{left}-{up}-{right}-{down}-{base}.
    • For unfolded: Colors should be provided in the format {front}-{left}-{up}-{right}-{down}-{back}-{base}.

Example Requests (Isometric)

  • Isometric view of a 3x3x3 cube with red on the left, white on the top, blue on the right, and black as the base:

    GET https://rubik-render.leoganpro.net/v1/cube/isometric/3x3x3/R-W-B-K

    Click to view the SVG image

  • Isometric view of a 3x3x3 cube with a "Chessboard" pattern, where opposite colors alternate:

    GET https://rubik-render.leoganpro.net/v1/cube/isometric/3x3x3/ROROROROR-WYWYWYWYW-BGBGBGBGB

    Click to view the SVG image

  • Isometric view of a 3x3x3 cube with a black base and completely gray cells:

    GET https://rubik-render.leoganpro.net/v1/cube/isometric/3x3x3/X

    Click to view the SVG image

  • Isometric view of an inverted 3x3x3 cube, where the white side is black, and the base is white:

    GET https://rubik-render.leoganpro.net/v1/cube/isometric/3x3x3/R-K-B-W

    Click to view the SVG image

  • Isometric view of a void 3x3x3 cube, where the centers are missing:

    GET https://rubik-render.leoganpro.net/v1/cube/isometric/3x3x3/RRRRTRRRR-WWWWTWWWW-BBBBTBBBB

    Click to view the SVG image

  • Isometric view of a 3x3x3 cube that shows an F2L situation solvable with the formula U R U' R':

    GET https://rubik-render.leoganpro.net/v1/cube/isometric/3x3x3/XXWRRXRRX-XXXXXXRRX-GGXXGGXGG

    Click to view the SVG image

  • Isometric view of a 2x3x2 cuboid known as the QiYi MofangGe 223 Cube:

    GET https://rubik-render.leoganpro.net/v1/cube/isometric/2x3x2/G-W-R

    Click to view the SVG image

  • Isometric view of a 3x3x3 cube showing the scramble from the Wikipedia image:

    GET https://rubik-render.leoganpro.net/v1/cube/isometric/3x3x3/BGGORRGGO-OOYYGYYOW-OGRGWRBWG

    Click to view the SVG image

  • Isometric view of a cute 1x1x1 Rubik's cube:

    GET https://rubik-render.leoganpro.net/v1/cube/isometric/1x1x1/R-W-B

    Click to view the SVG image

  • Isometric view of a Skewb with red, white, and blue sides:

    GET https://rubik-render.leoganpro.net/v1/skewb/isometric/1/R-W-B

    Click to view the SVG image

Example Requests (Flat)

  • Flat view of a 2x2 cube with yellow on the front, red on the left, blue on the top, orange on the right, and green on the bottom:

    GET https://rubik-render.leoganpro.net/v1/cube/flat/3x3/Y-R-B-O-G

    Click to view the SVG image

  • Flat view of a 3x3 cube showing an OLL case, known as the "T" shape:

    GET https://rubik-render.leoganpro.net/v1/cube/flat/3x3/XXYYYYXXY-YXY-XYX-X-XYX

    Click to view the SVG image

  • Flat view of a 7x7 cube with Among Us-themed artwork (inspired by the YouTube short):

    GET https://rubik-render.leoganpro.net/v1/cube/flat/7x7/WWWWWWWWWRRRWWWRRBBWWWRRRRWWWWRWRWWWWRWRWWWWWWWWW

    Click to view the SVG image

  • Flat view of a 2x2 Rubik's cube showing an OLL case called "Fish" with a transparent base:

    GET https://rubik-render.leoganpro.net/v1/cube/flat/2x2/XYXX-YX-XX-XY-YX-T

    Click to view the SVG image

Example Requests (Unfolded)

  • Unfolded view of a 3x3x3 solved cube with red, green, white, blue, yellow, and orange sides:

    GET https://rubik-render.leoganpro.net/v1/cube/unfolded/3x3x3/R-G-W-B-Y-O

    Click to view the SVG image

  • Unfolded view of a 4x3x2 cuboid with red, green, white, blue, yellow, and orange sides:

    GET https://rubik-render.leoganpro.net/v1/cube/unfolded/4x3x2/R-G-W-B-Y-O

    Click to view the SVG image

Color Notation

  • Each character corresponds to a color (see Color Mapping).
  • A hyphen - is used to separate sides, for example, {left_side}-{top_side}.
  • If a single letter is specified, for example, R, then all elements on that side will be red.
  • If more than one letter is specified, for example, RGB, then all elements on that side will be filled sequentially from left to right, top to bottom. If there are fewer letters than elements on the side, all remaining elements will be filled with the default color.
  • If no letter is specified, for example, --, then all elements on that side will be the default color.
    • Default color for the base - black K
    • Default color for sides - gray X
    • Default color for side elements in flat view - transparent T

Color Mapping

  • R: Red
  • G: Green
  • B: Blue
  • Y: Yellow
  • W: White
  • O: Orange
  • X: Gray
  • K: Black
  • T: Transparent

Planned Features

  • Add the following puzzles:
    • Cube (Cuboid)
    • Skewb
    • Pyraminx
    • Megaminx (Kilo-, Mega-, Giga-, Teraminx)
    • Square-1
  • Implement the following color options:
    • Various color presets
      • Standard
      • Pastel tones
      • Random colors
    • Ability to override colors
  • Conversion to PNG, JPG, etc.
  • Ability to draw arrows
  • Ability to rotate the image by n degrees

Installation

To run the service locally:

git clone https://github.com/Dunamis4tw/rubik-render.git
cd rubik-render
go mod tidy
go run main.go

The service will be available at http://localhost:80.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Inspiration

This project was inspired by Speedcubing.com.ua, where I first saw the concept of visualizing Rubik's cubes. I decided to build upon this idea, adding more customization and functionality.## Planned Features

About

A REST API for generating customizable SVG images of Rubik's cubes, allowing dynamic sizing and detailed color specification for each side.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages