# tile-mip-map

> Tile base mip mapping for texture atlases

Latest version **0.2.1** (published 2013-07-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install tile-mip-map
pnpm add tile-mip-map
yarn add tile-mip-map
bun add tile-mip-map
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2013-07-09 |
| First published | 2013-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Mikola Lysenko |
| Maintainers | mikolalysenko |
| Keywords | tile, mip, map, ndarray |

## Links

- npm: https://www.npmjs.com/package/tile-mip-map
- Repository: https://github.com/mikolalysenko/tile-mip-map
- Issues: https://github.com/mikolalysenko/tile-mip-map/issues
- npm.io page: https://npm.io/package/tile-mip-map

## Dependencies (3)

- [ndarray](https://npm.io/package/ndarray.md) ~1.0.3
- [ndarray-ops](https://npm.io/package/ndarray-ops.md) ~1.1.0
- [ndarray-downsample2x](https://npm.io/package/ndarray-downsample2x.md) ~0.1.0

## Recent versions

- 0.2.1 (latest) — 2013-07-09
- 0.2.0 — 2013-07-09
- 0.1.0 — 2013-07-03
- 0.0.2 — 2013-07-02
- 0.0.1 — 2013-07-02
- 0.0.0 — 2013-07-02

## README

tile-mip-map
============
Mip map generator for tiled texture atlases.

## Example

```javascript
var fs = require("fs")
var ndarray = require("ndarray")
var savePixels = require("save-pixels")

require("get-pixels")("./painterly.png", function(err, image) {

  //Cut 256x256x4 array into 16x16 tiles of width 16x16x4
  var tilemap = ndarray(image.data,
    [16, 16, 16, 16, 4],
    [16*16*16*4, 16*4, 16*16*4, 4, 1],
    0)
    
  //Compute mip pyramid
  var mipmap = require("tile-mip-map")(tilemap)

  //Save levels to images
  for(var i=0; i<mipmap.length; ++i) {
    var s = mipmap[i].shape
    var x = ndarray(mipmap[i].data, [s[0]*s[2], s[1]*s[3], s[4]])
    savePixels(x, "png").pipe(fs.createWriteStream(i + ".png"))
  }
})
```

Here is what the different mip levels look like:

#### 0:

<img src="https://raw.github.com/mikolalysenko/tile-mip-map/master/example/0.png">

#### 1:

<img src="https://raw.github.com/mikolalysenko/tile-mip-map/master/example/1.png">

#### 2:

<img src="https://raw.github.com/mikolalysenko/tile-mip-map/master/example/2.png">

#### 3:

<img src="https://raw.github.com/mikolalysenko/tile-mip-map/master/example/3.png">

#### 4:

<img src="https://raw.github.com/mikolalysenko/tile-mip-map/master/example/4.png">


## Install

    npm install tile-mip-map
    
### `require("tile-mip-map")(tilemap[, pad])`
Constructs a mip pyramid for the given tile map

* `tilemap` is a 5d array where the first two dimenions are the number of tiles, the next two are the width of each tile, and the last dimension is the number of channels.
* `pad` the number of times to pad each tile by.  default 1x

**Returns** A list of mip pyramids.

## Credits
(c) 2013 Mikola Lysenko. MIT License

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