npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cube-preview

v0.4.3

Published

Generate rubik's cube scramble images

Readme

Cube Preview

License: MIT code style: prettier

Contents

Installation

yarn add cube-preview
# or
npm install cube-preview

Usage

Basic Usage

CJS

const CubePreview = require('cube-preview');

const threeBythree = new CubePreview().svgString('RBLUULUBFRBDBRRBRFFDDFFRLFDBULDDFDLRURLLLDBLUFUBDBUUFR');

console.log(threeBythree);

Browser

<script src="cube-preview/bundle.min.js"></script>
<script>
 var threeBythree = new CubePreview().svgString('RBLUULUBFRBDBRRBRFFDDFFRLFDBULDDFDLRURLLLDBLUFUBDBUUFR');

 console.log(threeBythree);
</script>

basic

The state of the cube must be in the form

'UUUUUUUUUR...F...D...L...B...'
// or
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, ..., 2, ..., 3, ..., 4, ..., 5]

The string consists of 54 characters, 9 per face: U means a facelet of the up face color, R means a facelet of the right face color, etc.

The following diagram demonstrates the order of the facelets:

             +------------+
             | U1  U2  U3 |
             |            |
             | U4  U5  U6 |
             |            |
             | U7  U8  U9 |
+------------+------------+------------+------------+
| L1  L2  L3 | F1  F2  F3 | R1  R2  R3 | B1  B2  B3 |
|            |            |            |            |
| L4  L5  L6 | F4  F5  F6 | R4  R5  R6 | B4  B5  B6 |
|            |            |            |            |
| L7  L8  L9 | F7  F8  F9 | R7  R8  R9 | B7  B8  B9 |
+------------+------------+------------+------------+
             | D1  D2  D3 |
             |            |
             | D4  D5  D6 |
             |            |
             | D7  D8  D9 |
             +------------+

Advanced usage

setType

Set the type of puzzle to be drawn. Default is 333.

const twoByTwo = new CubePreview().setType('222').svgString('RDRBFRDFULBLDFUFBULURLBD');

 console.log(twoByTwo);

setType

Pyraminx
const pyraminx = new CubePreview().setType('pyram').svgString([2, 3, 1, 1, 1, 2, 0, 0, 2, 0, 3, 3, 1, 1, 0, 2, 2, 0, 1, 1, 1, 3, 3, 3, 3, 1, 2, 0, 0, 2, 2, 3, 0, 2, 3, 0,]);

console.log(pyraminx);

setType

Megaminx Last Layer
const megaLL = new CubePreview()
  .setType('minx')
  .svgString([
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    1,
    1,
    3,
    4,
    2,
    1,
    2,
    3,
    2,
    3,
    4,
    4,
    5,
    5,
    5,
  ]);

console.log(megaLL);

setType

setColorScheme

Set a custom color scheme. You only need to supply the colors you want to change.

const colored = new CubePreview()
  .setColorScheme({
    U: 'Black',
    R: 'Pink',
    F: '#39FF5A',
    B: 'DeepSkyBlue',
  })
  .svgString('RBLUULUBFRBDBRRBRFFDDFFRLFDBULDDFDLRURLLLDBLUFUBDBUUFR');

console.log(colored);

setColorScheme

The default color scheme :

defaultColorScheme = {
  U: 'white',
  R: 'red',
  F: 'green',
  D: 'yellow',
  L: 'orange',
  B: 'blue',
};

Status

Works for cubes from 2x2x2 to 7x7x7, pyraminx and megaminx LL.

Only output svg strings.