Scramble and image generator library for speed apps

isaacvr

Regular
Joined
Sep 23, 2024
Messages
74
Location
Cuba
Hello. I'm glad to announce the library called "cubicdb-module" on NPM (Node Package Manager). This tool can be used to generate high quality scrambles and images for all the major puzzles, with efficient svg representation to be displayed, stored, sent through the network and so on. Both operations (generate scrambles and images) can be executed on their own. The images have the same quality as in CubicDB since it uses the same style. There are some images of the generated puzzles:

1761059355002.png
1761059130779.png
1761059021243.png
1761059072667.png


1761059223756.png
1761059274317.png


To use the library and have more details about how it works, you can use this link. The library works for the browser (UMD), for ESM and NodeJS. Also is open source, you can see the code here and add some feature requests (on the Issues tab).
 
Hello. I'm glad to announce the library called "cubicdb-module" on NPM (Node Package Manager). This tool can be used to generate high quality scrambles and images for all the major puzzles, with efficient svg representation to be displayed, stored, sent through the network and so on. Both operations (generate scrambles and images) can be executed on their own. The images have the same quality as in CubicDB since it uses the same style. There are some images of the generated puzzles:

View attachment 43555View attachment 43552View attachment 43550View attachment 43551

View attachment 43553View attachment 43554

To use the library and have more details about how it works, you can use this link. The library works for the browser (UMD), for ESM and NodeJS. Also is open source, you can see the code here and add some feature requests (on the Issues tab).
nice skewb and squan scramble
 
This tool can be used to generate high quality scrambles and images for all the major puzzles
Do you have more information on this?

It seems you've vendored csTimer code for scrambling (which does generate proper scrambles), but this example in the README encourages / makes it look easy to get bad scrambles:

const scrambles = getScrambles([
{ scrambler: "333", length: 20 },
{ scrambler: "222", length: 11 },
]);
 
Do you have more information on this?
Yes and no. I do use CSTimer code to generate the scrambles, with all what it takes to do it (licence and so on) and yes, that's part of the examples but no, it doesn't make bad scrambles. It also doesn't make sense to be like that in the README, which I already updated (thanks btw for your reply). For 3x3 and 2x2, it doesn't matter the "length" parameter, so you'll always get a proper scramble. Thanks again.
 
Is there any documentation on how to use it at user level and developer level?
The readme of the repository contains some useful information about it with different cases and even the result of benchmarks over the scramble and image generation with the explanation of those statistics and also with the current state of the scramble parser (for image generation) on different puzzles. There's no web page for it (yet).
 
really good! thanks for your contribuition

index.js
JavaScript:
import { genImages } from "cubicdb-module";
import fs from 'fs';

// Get the algorithm and type from the command line arguments
const algorithm = process.argv[2]; // The third argument (index 2) will be the algorithm
const type = process.argv[3]; // The fourth argument (index 3) will be the type

if (!algorithm || !type) {
    console.error('Please provide both algorithm and type as command line arguments.');
    process.exit(1); // Exit the script if either algorithm or type is missing
}

const result = genImages([{
    scramble: algorithm,
    type: type
}]);

// Check if result is an array and get the first element if it is
const svgData = Array.isArray(result) ? result[0] : result;

// Write the SVG data to a file
fs.writeFile('image.svg', svgData, (err) => {
    if (err) {
        console.error('Error writing to file:', err);
    } else {
        console.log('Successfully wrote to image.svg');
    }
});

package.json
JSON:
{
  "name": "cybic_module",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "node index.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "cubicdb-module": "^1.0.6"
  }
}

1761404869255.png
 
@Filipe Teixeira That's great. It should be also a good thing if you can pass the name of the file as an argument, or to have like a template string with custom parameters like this:

"%i- Image.svg"
"%i- Image-%t.svg"

where %i is the index of the image (in case you want to generate multiple images) and %t is the timestamp (to save unique file names), or something like that. The posibilities are endless.

I want to create a simple web app to do this where you can generate scrambles and be able to download them as a zip or something similar. But this approach is also good, you can install it as a global npm package and have your images and scrambles from CLI.
 
@Filipe Teixeira That's great. It should be also a good thing if you can pass the name of the file as an argument, or to have like a template string with custom parameters like this:

"%i- Image.svg"
"%i- Image-%t.svg"

where %i is the index of the image (in case you want to generate multiple images) and %t is the timestamp (to save unique file names), or something like that. The posibilities are endless.

I want to create a simple web app to do this where you can generate scrambles and be able to download them as a zip or something similar. But this approach is also good, you can install it as a global npm package and have your images and scrambles from CLI.
good idea.

that was a quick test, but yes, the possibilities are endless.

I'll try to make a 3d visualization of the NxN puzzles by using the svg as a texture.

I made that with my own NxN simulator, I have implementation in webgl with threejs and also with plain css

webgl threejs implementation

css implementation
 
Back
Top