https://github.com/dy/clip-pixels
Slice rectangle from pixels array
https://github.com/dy/clip-pixels
Last synced: 11 months ago
JSON representation
Slice rectangle from pixels array
- Host: GitHub
- URL: https://github.com/dy/clip-pixels
- Owner: dy
- Created: 2018-10-23T11:30:33.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-23T11:43:56.000Z (over 7 years ago)
- Last Synced: 2025-05-16T06:18:43.974Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
[](https://travis-ci.org/dy/clip-pixels)
Slice rectangle from an array with pixels.
### `clip(arr, shape=[w, h?, channels=4], rect=[x, y?, w?, h?])`
```js
var clip = require('clip-pixels')
var pixels = [
0, 1, 0,
1, 1, 1,
0, 1, 0
]
pixels = clip(pixels, [3, 3, 1], [1, 0, 2, 3])
/*
1, 0,
1, 1,
1, 0
*/
```
See also [flip-pixels](https://ghub.io/flip-pixels).