zcursor
v1.1.14
Published
zcursor is a fork of the npm builds of xcursor, brought into the modern day, as the upstream github repository is now dead
Downloads
33
Maintainers
Readme
ZCursor
A rework of the NPM xcursor package, which's repository is now a dead link. An archive of what was found via a combination of multiple NPM versions, representing the github repository as close as possible, can be found on the upstream-archive branch.
This project attempts to modernize it by rewriting it in TypeScript using modern TS classes, rather than properties on prototypes of functions, in addition to using esbuild to properly build the project. It retains a very similar API to xcursor; migrating can, in some cases, be as simple as a drop-in.
Installation
pnpm i zcursor
Usage
Decoding a cursor
import { Decoder } from 'zcursor';
import { readFileSync, writeFileSync } from 'fs';
const arrowData = readFileSync('cursor.cur');
const decoder = new Decoder(arrowData);
for (let i = 0; i < decoder.images(); i++) {
// Loop through all frames of the cursor
const image = decoder.imageInfo(i);
const filename = join(outdir, image.type + '-' + i + '.data'); // Generate a filename
const data = decoder.getData(image); // Uint8Array of the image data, BGRA for some reason
writeFileSync(filename, Buffer.from(data)); // Write the data to a file
}
Encoding a cursor
TBA, read the examples or freebata for the time being.
Examples
See examples for detailed usage guides.