emilgoldsmith/elm-speedcubing/8.0.0

NOTE: the latest version is 14.1.0

Cube.Advanced

Definition

type Cube

See Cube

Constructors

Modifiers

Displayers

List (Attribute msg)
-> { pixelSize : Int
, displayAngle : DisplayAngle
, annotateFaces : Bool
}
-> Cube
-> Html msg

With Animation

Check out the example on Github to see how the different functions interact with each other

List (Attribute msg)
-> { animationState : AnimationState
, toMsg : AnimationMsg -> msg
, pixelSize : Int
, displayAngle : DisplayAngle
, annotateFaces : Bool
}
-> Cube
-> Html msg
{ toMsg : AnimationMsg -> msg
, animationDoneMsg : msg
}
-> ( AnimationState, Cmd msg )

Rendering

type alias Rendering =
{ ufr : CubieRendering
, ufl : CubieRendering
, ubl : CubieRendering
, ubr : CubieRendering
, dfr : CubieRendering
, dfl : CubieRendering
, dbl : CubieRendering
, dbr : CubieRendering
, uf : CubieRendering
, df : CubieRendering
, db : CubieRendering
, ub : CubieRendering
, ur : CubieRendering
, ul : CubieRendering
, dl : CubieRendering
, dr : CubieRendering
, fl : CubieRendering
, fr : CubieRendering
, br : CubieRendering
, bl : CubieRendering
, u : CubieRendering
, d : CubieRendering
, f : CubieRendering
, b : CubieRendering
, l : CubieRendering
, r : CubieRendering
}

This representation of how the cube looks is meant for advanced custom use if you for some reason want to display the cube differently than this package does, or you need to introspect specific state of the cube for some application.

It is expected that most use cases should be able to fulfill your goals without the use of this, and if you find a use case that you think should be covered by the package itself feel free to submit a Github issue.

Otherwise as mentioned use these rendering methods and types to accomplish all the custom goals you want to!

type alias CubieRendering =
{ u : Color
, d : Color
, f : Color
, b : Color
, l : Color
, r : Color
}

The rendering of one specific cubie (a cubie is one of the pieces of the Rubik's Cube). Note that we describe all sides of all cubies in this model, even the ones that aren't facing outwards.

type Color
= UpColor
| DownColor
| FrontColor
| BackColor
| LeftColor
| RightColor
| PlasticColor

The color of a face of a cubie. The name of the color corresponds to the face of the cube that it belongs to in the initial orientation. So in standard scrambling orientation of the 3x3 cube UpColor is white and RightColor is red. PlasticColor means it is a part of the cubie not facing outwards

render : Cube -> Rendering

Get a Rendering of a cube

Rendering Helpers

type Face
= UpOrDown UOrD
| FrontOrBack FOrB
| LeftOrRight LOrR

Describes all the possible faces of a cubie (a piece on the cube)

type UOrD
= U
| D

A helper type that allows us to make it impossible to represent impossible locations on the cube. By splitting the faces into opposites like we've done with these 3 types we can describe that a corner location is exactly described by one of each of three opposing faces, and not any two faces, and similarly for edges

type LOrR
= L
| R

Same as UOrD

type FOrB
= F
| B

Same as UOrD

A helper constructor for the U face as it's much neater to read than UpOrDown U

A helper constructor for the D face as it's much neater to read than UpOrDown D

A helper constructor for the R face as it's much neater to read than LeftOrRight R

A helper constructor for the L face as it's much neater to read than LeftOrRight L

A helper constructor for the F face as it's much neater to read than FrontOrBack F

A helper constructor for the B face as it's much neater to read than FrontOrBack B

Get the color corresponding to the given face

setColor : Face -> Color -> CubieRendering -> CubieRendering

Set the given color on the given face of the given cubie rendering

faces : Nonempty Face

All possible faces

import List.Nonempty


List.Nonempty.length faces --> 6
type alias CornerLocation =
( UOrD, FOrB, LOrR )

Describes all the possible locations of a corner on a cube

getCorner : CornerLocation -> Cube -> OrientedCorner

Get the corner at the given location of the given cube

setCorner : CornerLocation -> OrientedCorner -> Cube -> Cube

Set the given corner at the given corner location on the given cube

cornerLocations : Nonempty CornerLocation

All possible corner locations

import List.Nonempty


List.Nonempty.length cornerLocations --> 8
= M ( UOrD, FOrB )
| S ( UOrD, LOrR )
| E ( FOrB, LOrR )

Describes all the possible locations of an edge on a cube

getEdge : EdgeLocation -> Cube -> OrientedEdge

Get the edge at the given location on the given cube

setEdge : EdgeLocation -> OrientedEdge -> Cube -> Cube

Set the given edge at the given location of the given cube

All possible edge locations

import List.Nonempty


List.Nonempty.length edgeLocations --> 12

Describes all the possible locations of a center on a cube

Get the center at the given location on the given cube

setCenter : CenterLocation -> Center -> Cube -> Cube

Set the given center at the given location on the given cube

All possible center locations

import List.Nonempty


List.Nonempty.length centerLocations --> 6

Algorithm Helpers