cubing / cubing.js

🛠 A library for displaying and working with twisty puzzles. Also currently home to the code for Twizzle.
https://js.cubing.net/cubing/
GNU General Public License v3.0
249 stars 45 forks source link

v2 API Wishlist #52

Closed lgarron closed 4 years ago

lgarron commented 9 years ago

Working Draft:

Classes

Classes implemented using prototypes. All setters should also have a getter.

Twisty

Twisty.animation.setSpeed(ratio);
Twisty.animation.playForwards();
Twisty.animation.playBackwards();
Twisty.animation.pause();
Twisty.animation.playSingleMoveForwards();
Twisty.animation.playSingleMoveBackwards();
Twisty.animation.skipToStart();
Twisty.animation.skipToEnd();
Twisty.animation.setPosition(ms, "animateQuickly" | "immediate")
Twisty.setup.setSolvedState(TwistyState)
Twisty.setAlg(TwistyAlg)

Twisty3x3x3 (prototype: Twisty)

TwistyState

A TwistyState is a ksolve-like extension of the idea of a permutation.

TwistyState.fromAlg()
TwistyState.invert() @returns TwistyState
TwistyState.compose(TwistyState) @returns TWistyState

AnimatingTwistyState

TwistyState.fromAlg()
TwistyState.invert() ?

Alg

An alg is a collection of moves and other algs. Can be either a straight move sequence, or a group/communtator/conjugate.

Alg.addMoves(?)
Alg.timestampToToken(ms) @returns AlgToken
Alg.tokenToTimestamp(AlgToken) @returns ms
Alg.reparse("<original alg> R U R'")

Alg3x3x3 (prototype: Alg)

AlgToken

DOMAlg ?

// Something for highlighting

TwistyView

new TwistyView(rendererType, div);
  (rendererType == canvas, CSS div, etc.)
  // support shadow DOM where possible?
TwistyView.addPuzzle(puzzle);
TwistyView.setCameraLocation(coords)
TwistyView.fullscreen();
  // Perhaps the client can just use the normal HTML5 API on the div?
// 2-axis View rotation support support

Convenience

Twisty.emulateAnimCubeApplet()
Twisty.emulateRandelshoferApplet()
Twisty.emulateRoofpig

TwistySolver

TwistySolver.solveState(); @returns Alg

TODO

lgarron commented 4 years ago

We actually have all of these by now (even if not ergonomically organized)!