XCursor extracted from the package, and refactored to TypeScript https://npm.im/zcursor
Go to file
Exponential-Workload 5d38b0e942
All checks were successful
Lint & Test / test (push) Successful in 55s
chore: update
2024-03-04 23:26:25 +01:00
.changeset
.forgejo/workflows
examples
ico
src
.gitignore
.npmignore
.npmrc
.prettierignore
.prettierrc
CHANGELOG.md
jest.config.cjs
LICENSE
package.json
pnpm-lock.yaml
README.md
tsconfig.json

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.