zcursor
TypeScript icon, indicating that this package has built-in type declarations

1.1.14 • Public • Published

ZCursor Logo

ZCursor

License
NPM Codeberg
Upstream Examples

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.

Package Sidebar

Install

npm i zcursor

Weekly Downloads

4

Version

1.1.14

License

MIT

Unpacked Size

188 kB

Total Files

50

Last publish

Collaborators

  • exponentialworkload