image-in-browser
Version:
Package for encoding / decoding images, transforming images, applying filters, drawing primitives on images on the client side (no need for server Node.js)
24 lines • 668 B
JavaScript
export class PixelRangeIterator {
constructor(pixel, x, y, width, height) {
this._pixel = pixel;
this._x1 = x;
this._y1 = y;
this._x2 = x + width - 1;
this._y2 = y + height - 1;
this._pixel.setPosition(x - 1, y);
}
next() {
if (this._pixel.x + 1 > this._x2) {
this._pixel.setPosition(this._x1, this._pixel.y + 1);
return {
done: this._pixel.y > this._y2,
value: this._pixel,
};
}
return this._pixel.next();
}
[Symbol.iterator]() {
return this;
}
}
//# sourceMappingURL=pixel-range-iterator.js.map