8000 GitHub - meriadec/PixelartJS: A simple tool for generating pixel art
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

meriadec/PixelartJS

Repository files navigation

Coverage Status JS.ORG

WTF is that?

PixelartJS is a small tool which allows you to generate canvas images from characters. It's purpose is to be customizable as well, for the moment you change parameters like color, set a color map (by character), and specify the size of the pixels in the generated image.

I'm open to any suggestions, feel free to ask / pull request !

DEMO

Install

bower install pixelart --save

Add dependency:

<script src="bower_components/pixelart/dist/pixelart.min.js"></script>

Usage

Basic

<div id="myImage"></div>
var target = document.getElementById('myImage');
var ascii  = [
  'oooo o  o',
  'o  o o o',
  'o  o o o',
  'oooo o  o'
];

new Pixelart(target, ascii, {
  // options here (optional)
});

Pass an array of ascii for cool animated sprites :)

// ultra basic pixelart loader
new Pixelart(
  target,
  [
    ['o'],
    [' o'],
    ['  o']
  ],
  { speed: 200, loop: true }
);

Options

pixelSize

Type: Number

Size in pixels of each square.

new Pixelart(target, ascii, { pixelSize: 2 });

color

Type: String (hex color)

Default color for all non-blank characters.

new Pixelart(target, ascii, { color: '#FF0000' });

colorMap

Type: Object

Specify color for specific characters.

new Pixelart(
  target,
  ascii,
  {
    colorMap: {
      a: '#FF0000',
      b: '#00FF00',
      c: '#0000FF'
    }
  }
});

stagger

Type: Number (of milliseconds)

"Animate" drawing by putting delay between each block draw.

new Pixelart(
  target,
  ascii,
  {
    stagger: 50
  }
});

speed

Type: Number (of milliseconds)

Delay between each frame, when passing an array of sprites. (default 1000ms)

new Pixelart(
  target,
  [
    [
      'o',
      ' o',
      'o',
    ],
    [
      '  o',
      '   o',
      '  o',
    ],
  ],
  {
    speed: 50
  }
});

License

BSD

About

A simple tool for generating pixel art

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  • 39C5
  •  
  •  
0