Socket
Socket
Sign inDemoInstall

sixel-decoder

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sixel-decoder

Sixel decoder


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Sixel Decoder

Sixel decoder for JavaScript

GitHub stars Twitter Follow

Example images where taken from this repo

Installation

npm install --save sixel-decoder
yarn add sixel-decoder

Example usage

See result here

import { SixelReader, PixelsWriter } from 'sixel-decoder';

const images = {
  map8: require('../images/map8.six'),
  map16: require('../images/map16.six'),
  snake: require('../images/snake.six'),
  vimperator3: require('../images/vimperator3.six'),
};

const canvas = document.querySelector('canvas');
const ctx = canvas.getContext('2d');

const buttonsContainer = document.createElement('div');

Object.keys(images).forEach(key => {
  const button = document.createElement('button');
  button.id = key;
  button.textContent = key;

  buttonsContainer.appendChild(button, canvas);
});

document.body.insertBefore(buttonsContainer, canvas);

document.body.addEventListener('click', e => {
  if (!e.target.matches('button')) {
    return;
  }

  const id = e.target.id;
  const sixelString = images[id];

  const decoder = new SixelReader();
  decoder.setString(sixelString);
  decoder.readConfig();

  const { width, height } = decoder.size;

  canvas.width = width;
  canvas.height = height;

  const pixels = new Uint8ClampedArray(width * height * 4);
  const writer = new PixelsWriter(pixels, { width, height });

  decoder.readSixels(writer.onSixel, writer.onCaretMove);

  const imageData = new ImageData(pixels, width, height);

  ctx.putImageData(imageData, 0, 0, 0, 0, width, height);
});

TODO

  • Support WebGL

License

MIT

Author

Andrei Lesnitsky

FAQs

Package last updated on 17 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc