A TypeScript library for importing, creating, manipulating, and exporting PXON data.
- π² Tree-shakable: Import only what you need
- π Multiple formats: ESM, CommonJS, and UMD bundles
- π Type-safe: Full TypeScript support with type definitions
- π± Universal: Works in Node.js and browsers
npm install pxon
PXON supports multiple import styles to fit your needs:
import { PXON } from 'pxon';
const pxon = new PXON();
const { PXON } = require('pxon');
const pxon = new PXON();
<!-- Production (minified) -->
<script src="https://unpkg.com/pxon/dist/browser/pxon.min.js"></script>
<!-- Development (with helpful errors) -->
<script src="https://unpkg.com/pxon/dist/browser/pxon.js"></script>
<script>
// The library is available as a global variable
const pxon = new PXON();
</script>
import { PXON } from 'pxon';
const pxon = new PXON();
// Import PXON-formatted JSON.
pxon.import({
exif: {
artist: 'Matthew Hudson',
software: 'https://make8bitart.com/'
},
pxif: {
pixels: []
}
});
// Set some EXIF data.
pxon.artist = 'Matthew Hudson';
pxon.software = 'https://make8bitart.com/';
// Set a single pixel's value.
pxon.setPixel({ x: 0, y: 0, color: 'rgba(0, 0, 0, 1)', size: 1 });
// Get all pixels as an array
const allPixels = pxon.getAllPixels();
// Get a specific pixel
const pixel = pxon.getPixel(0, 0);
// Returns a PXON-formatted object.
console.log(pxon.export());
- PXON Specification - specs for the "pixel art object notation" format
- make8bitart.com - pixel art painting app
- pxonloop - a pxon playground
- image-to-pxon - app that converts image to pxon
- The non-canonical
dataURL
field is not currently supported. - The non-canonical
size
field defaults to1
.
# Install dependencies
npm install
# Run development build with watch mode
npm run dev
# Run tests
npm test
# Build for production
npm run build
# Generate API documentation
npm run docs
# Serve API documentation locally
npm run docs:serve
PXON is compatible with all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js v22+. The library uses ES2020 features, so for older browser support, consider using a bundler with appropriate polyfills.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes using Conventional Commits format
- Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the ISC License - see the LICENSE file for details.