# mixel

> A rewrite of pixel-sprite-generator in Typescript.

Latest version **1.0.4** (published 2018-06-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install mixel
pnpm add mixel
yarn add mixel
bun add mixel
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2018-06-15 |
| First published | 2018-06-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 123.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Kyle Kemp |
| Maintainers | seiyria |
| Keywords | pixel-sprite-generator, pixel, sprite, generator |

## Links

- npm: https://www.npmjs.com/package/mixel
- Repository: https://github.com/seiyria/mixel
- Homepage: https://github.com/seiyria/mixel#readme
- Issues: https://github.com/seiyria/mixel/issues
- npm.io page: https://npm.io/package/mixel

## Dependencies (1)

- [seedrandom](https://npm.io/package/seedrandom.md) ^2.4.3

## Recent versions

- 1.0.4 (latest) — 2018-06-15
- 1.0.3 — 2018-06-15
- 1.0.2 — 2018-06-15
- 1.0.1 — 2018-06-13
- 1.0.0 — 2018-06-13

## README

# mixel

A rewrite of [pixel-sprite-generator](https://github.com/zfedoran/pixel-sprite-generator) in Typescript.

Other changes:

* Added ability to tint sprites
* Added seedable RNG

## Install

`npm i mixel`

## Examples

See [here](https://mixel.stackblitz.io) for a list of visual examples.

## Usage

### Sample Usage
```typescript
const SPACESHIP_MASK: Mask = {
  width: 6,
  height: 12,
  mirrorX: true,
  data: [
    0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 1, 1,
    0, 0, 0, 0, 1,-1,
    0, 0, 0, 1, 1,-1,
    0, 0, 0, 1, 1,-1,
    0, 0, 1, 1, 1,-1,
    0, 1, 1, 1, 2, 2,
    0, 1, 1, 1, 2, 2,
    0, 1, 1, 1, 2, 2,
    0, 1, 1, 1, 1,-1,
    0, 0, 0, 1, 1, 1,
    0, 0, 0, 0, 0, 0  
  ]
};

for(let i = 0; i < SPRITE_COUNT; i++) {
  const sprite = new Sprite(SPACESHIP_MASK, {
    colored: true
  });

  const canvas = createCanvas(sprite);
  document.getElementById('spaceship-default-settings').appendChild(canvas);
}
```

### API

#### `Mask`

A `Mask` is the general shape of the generated object. It supports these parameters:

Name | Type | Default | Description
---- | ---- | ------- | -----------
`width` | number | 0 | The number of pixels wide the mask should be (if `mirrorX` is set, will be doubled).
`height` | number | 0 | The number of pixels tall the mask should be (if `mirrorY` is set, will be doubled).
`mirrorX` | boolean | false | Whether the mask should mirror across the Y axis (from left to right).
`mirrorY` | boolean | false | Whether the mask should mirror across the X axis (from top to bottom).
`data` | SpriteStructure[] | [] | An array of values (-1..2) representing a `SpriteStructure` value.

#### `SpriteOptions`

`SpriteOptions` are specifically used in the manipulation of the sprite.

Name | Type | Default | Description
---- | ---- | ------- | -----------
`colored` | boolean | false | Whether or not the sprite should have color.
`edgeBrightness` | number (0, 1) | 0.3 | How bright the edges of the sprite should be.
`colorVariations` | number (0, 1) | 0.2 | Higher numbers make the color variations within a sprite more frequent.
`brightnessNoise` | number (0, 1) | 0.3 | Higher numbers make the brightness more "fuzzy" near the edge.
`saturation` | number (0, 1) | 0.5 | Higher numbers make the general saturation of the image appear more colorful.
`seed` | string | none | The seed to use for random generation. Using the same seed/mask will result in the same image every time.
`tint` | `{ r: number, g: number, b: number, a: number }` | none | The tint to apply to the image when it's been generated.
`randomSampleCallback` | `(x: number, y: number) => SpriteStructure` | Randomly change 1/2 to -1/0 | The callback to be applied to each individual cell of the sprite.

### More Usage

Check the editor [here](https://stackblitz.com/edit/mixel?file=index.ts) to see more examples.

---
_Source: https://npm.io/package/mixel · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
