diagrams-rubiks-cube-0.1.0.0: Library for drawing the Rubik's Cube.

Safe HaskellNone
LanguageHaskell2010

Diagrams.RubiksCube.Draw

Synopsis

Documentation

drawSide Source

Arguments

:: Renderable (Path R2) b 
=> R2

dx

-> R2

dy

-> Side (Colour Double) 
-> Diagram b R2 

Draws one 3x3 side of the cube.

drawFoldingPattern :: Renderable (Path R2) b => RubiksCube (Colour Double) -> Diagram b R2 Source

Draw the folding pattern of the cube. The front side is at the center of the pattern.

drawRubiksCube :: Renderable (Path R2) b => Offsets -> RubiksCube (Colour Double) -> Diagram b R2 Source

Draw the Rubik's cube in parallel perspective.

import Diagrams.RubiksCube
import Control.Lens
drawCubeExample =
  let c = solvedRubiksCube ^. undoMoves [R,U,R',U']
  in drawRubiksCube with c

drawMove :: Renderable (Path R2) b => Move -> Offsets -> RubiksCube (Colour Double) -> Diagram b R2 Source

Draw the Rubik's cube in parallel perspective with an arrow indicating the next move. If the the bottom layer is moved, the cube will be shown from below.

import Diagrams.RubiksCube
import Control.Lens
drawMoveExample =
  let c = solvedRubiksCube ^. undoMoves [L,U,L',U']
  in drawMove L with c

data MovesSettings Source

Constructors

MovesSettings 

Fields

_moveSep :: Double

space between cubes

_showStart :: Bool

show the start configuration?

_showEnd :: Bool

show the end configuration?

_offsets :: Offsets
 

drawMoves Source

Arguments

:: Renderable (Path R2) b 
=> MovesSettings 
-> RubiksCube (Colour Double)

the start configuration

-> [Move] 
-> Diagram b R2 

Draws a sequence of moves.

import Diagrams.RubiksCube
import Control.Lens
drawMovesExample =
  let moves = [R, F', R', D', F, F]
      startPos = solvedRubiksCube ^. undoMoves moves
      settings = with & showStart .~ True
  in drawMoves settings startPos moves

drawMovesBackward Source

Arguments

:: Renderable (Path R2) b 
=> MovesSettings 
-> RubiksCube (Colour Double)

the end configuration

-> [Move] 
-> Diagram b R2 

Like drawMoves, but takes the end configuration instead of the start configuration. The previous example can be simplified with this:

import Diagrams.RubiksCube
import Control.Lens
drawMovesExample' =
  let moves = [R, F', R', D', F, F]
      endPos = solvedRubiksCube
      settings = with & showStart .~ True
  in drawMovesBackward settings endPos moves