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
- Host: GitHub
- URL: https://github.com/semibran/img-tile
- Owner: semibran
- License: mit
- Created: 2018-03-14T18:38:21.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-14T18:38:30.000Z (over 8 years ago)
- Last Synced: 2025-09-28T09:51:30.747Z (9 months ago)
- Topics: image, img, sprite, spritesheet, tile
- Language: JavaScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# img-tile
> tile an `
` from a given width and height

```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