Skip to content

Commit 200dbe1

Browse files
committed
deprecate coordinates()
1 parent 34227d4 commit 200dbe1

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 3.20.3
4+
5+
### Deprecated
6+
7+
- **`image.coordinates()`** is deprecated and will be removed in 4.0, like iterating over the image (`for (const [x, y] of image)`), which now points to `pixels()` instead of `coordinates()`. Use `for (const [x, y] of image.pixels())`: `pixels()` yields `[x, y, color]`, so the color comes with the position.
8+
39
## 3.20.2
410

511
### Fixes

‎src/image.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,8 @@ export class Image {
783783
/**
784784
* Yields an [x, y] array for every pixel in the image (0-based), row by row
785785
* @yields The coordinates of the pixel ([x, y])
786+
* @deprecated Use {@link Image.pixels}, which yields `[x, y, color]`: `coordinates()` will be removed in 4.0
787+
* @group Deprecated
786788
*/
787789
*coordinates(): Generator<[x: number, y: number], void, undefined> {
788790
for (let y = 0; y < this.height; y++)
@@ -805,7 +807,7 @@ export class Image {
805807
/**
806808
* Yields an [x, y] array for every pixel in the image (0-based)
807809
* @yields The coordinates of the pixel ([x, y])
808-
* @deprecated Use {@link Image.coordinates}, iterating over the image will be removed in 4.0
810+
* @deprecated Use {@link Image.pixels}, which yields `[x, y, color]`: iterating over the image will be removed in 4.0
809811
* @group Deprecated
810812
*/
811813
*[Symbol.iterator](): Generator<[x: number, y: number], void, undefined> {

‎tests/regressions.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ const rgba = (image, x, y) => Image.colorToRGBA(image.getPixelAt(x, y));
440440
assert(animation.width === 6 && animation.height === 4 && [...animation].every((f, i) => same(f, other[i])), 'Animation.resize({height})');
441441
}
442442

443-
// coordinates() and pixels(), the iterator and iterateWithColors() (deprecated, removed in 4.0) yield the same
443+
// coordinates(), pixels(), the iterator and iterateWithColors() (all but pixels() deprecated, removed in 4.0) yield the same
444444
{
445445
const image = new Image(3, 2).fill((x, y) => ColorHelpers.fromRGBA(x * 50, y * 100, 7, 255));
446446
const coordinates = [...image.coordinates()], pixels = [...image.pixels()];

0 commit comments

Comments
 (0)