An open API service indexing awesome lists of open source software.

https://github.com/semibran/img-tile

tile an <img> from a given width and height
https://github.com/semibran/img-tile

image img sprite spritesheet tile

Last synced: 8 months ago
JSON representation

tile an <img> from a given width and height

Awesome Lists containing this project

README

          

# img-tile
> tile an `` from a given width and height

![mario tileset split into 16x16 fragments](img/tiles.png)

```js
const tile = require("img-tile")
const load = require("img-load")

load("./tiles.png", (err, image) => {
if (err) throw err
let tiles = tile(image, 16, 16)
for (let tile of tiles) {
document.body.appendChild(tile)
}
})
```

## usage
[![npm badge]][npm package]

### `tile(image, width, height) -> images`
Splits the given `image` into individual `` elements of the dimensions described by `width` and `height`.

* `image`: The `HTMLImageElement` to be split
* `width`: The desired width of each resulting `` element
* `height`: The desired height of each resulting `` element

[npm package]: https://www.npmjs.org/package/img-tile
[npm badge]: https://nodei.co/npm/img-tile.png?mini