diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e7f12c..92cfd37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.1.0-alpha+1 + +- Upgraded to `lodim ^0.1.6`, which now hosts some of the original functionality + of this package in a more general-purpose way (i.e. `fill`, `copy`, ...). + ## 0.1.0-alpha Initial preview release 🎉! diff --git a/example/example.dart b/example/example.dart index d5b8bf2..23b30d7 100755 --- a/example/example.dart +++ b/example/example.dart @@ -18,7 +18,7 @@ void main() { final blue = (y / (imageHeight / 2) * 255).toInt(); image.fill( abgr8888.create(blue: blue), - target: Rect.fromLTWH(0, y, imageWidth, 1), + Rect.fromLTWH(0, y, imageWidth, 1), ); } diff --git a/lib/src/buffer.dart b/lib/src/buffer.dart index 4d909ef..20ae1f4 100644 --- a/lib/src/buffer.dart +++ b/lib/src/buffer.dart @@ -1,5 +1,6 @@ import 'dart:typed_data'; +import 'package:lodim/lodim.dart' as lodim; import 'package:pxl/src/blend.dart'; import 'package:pxl/src/format.dart'; import 'package:pxl/src/geometry.dart'; @@ -196,36 +197,6 @@ abstract base mixin class Buffer { return _ScaledBuffer(this, scale); } - /// Returns a lazy iterable of pixels in the buffer from [start] to [end]. - /// - /// The returned iterable will contain all pixels in the buffer that are - /// within the rectangle defined by [start] and [end], inclusive. - /// - /// The provided positions are clamped to the bounds of the buffer, and yield - /// no pixels if `start > end`. - Iterable getRange(Pos start, Pos end) { - final bottomRight = bounds.bottomRight; - start = start.clamp(Pos.zero, bottomRight); - end = end.clamp(Pos.zero, bottomRight); - if (Pos.byRowMajor(start, end) > 0) { - return const Iterable.empty(); - } - return getRangeUnsafe(start, end); - } - - /// Returns a lazy iterable of pixels in the buffer from [start] to [end]. - /// - /// The returned iterable will contain all pixels in the buffer that are - /// within the rectangle defined by [start] and [end], inclusive. - /// - /// The provided positions must be `(0, 0) <= start <= end < (width, height)` - /// or the behavior is undefined. - Iterable getRangeUnsafe(Pos start, Pos end) { - final iStart = start.y * width + start.x; - final iEnd = end.y * width + end.x; - return data.skip(iStart).take(iEnd - iStart + 1); - } - /// Returns a lazy iterable of pixels in the rectangle defined by [rect]. /// /// The returned iterable will contain all pixels in the buffer that are @@ -233,7 +204,9 @@ abstract base mixin class Buffer { /// /// The provided rectangle is clamped to the bounds of the buffer and yields /// no pixels if the rectangle is empty. - Iterable getRect(Rect rect) => getRectUnsafe(rect.intersect(bounds)); + Iterable getRect(Rect rect) { + return getRectUnsafe(rect.intersect(bounds)); + } /// Returns a lazy iterable of pixels in the rectangle defined by [rect]. /// @@ -243,10 +216,7 @@ abstract base mixin class Buffer { /// The provided rectangle must be contained within the bounds of the buffer /// or the behavior is undefined. Iterable getRectUnsafe(Rect rect) { - if (rect.width == width) { - return getRangeUnsafe(rect.topLeft, rect.bottomRight - const Pos(1, 1)); - } - return rect.positions.map(getUnsafe); + return lodim.getRect(rect, getUnsafe); } @override diff --git a/lib/src/buffer/pixels.dart b/lib/src/buffer/pixels.dart index adec631..758285c 100644 --- a/lib/src/buffer/pixels.dart +++ b/lib/src/buffer/pixels.dart @@ -19,18 +19,6 @@ abstract final class Pixels with Buffer { }) : assert(width > 0, 'Width must be greater than zero.'), assert(height > 0, 'Height must be greater than zero.'); - /// Raw bytes of pixel data. - /// - /// This type is exposed for operations that require direct access to the - /// underlying memory, such as [copying pixel data to a canvas][1], or - /// [transferring bytes to an isolate][2]; in most cases the other methods - /// provided by [Pixels] will be used instead. - /// - /// [1]: https://pub.dev/documentation/web/latest/web/ImageData/ImageData.html - /// [2]: https://api.dart.dev/stable/3.5.1/dart-isolate/TransferableTypedData-class.html - @override - TypedDataList get data; - @override final PixelFormat format; @@ -40,28 +28,15 @@ abstract final class Pixels with Buffer { @override final int height; - int _indexAtUnsafe(Pos pos) => pos.y * width + pos.x; - - @override - @unsafeNoBoundsChecks - T getUnsafe(Pos pos) => data[_indexAtUnsafe(pos)]; - /// Sets the pixel at the given position. /// /// If outside the bounds of the buffer, does nothing. - void set(Pos pos, T pixel) { - if (contains(pos)) { - setUnsafe(pos, pixel); - } - } + void set(Pos pos, T pixel); /// Sets the pixel at the given position **without bounds checking**. /// /// If outside the bounds of the buffer, the behavior is undefined. - @unsafeNoBoundsChecks - void setUnsafe(Pos pos, T pixel) { - data[_indexAtUnsafe(pos)] = pixel; - } + void setUnsafe(Pos pos, T pixel); /// Clears the buffer to the [PixelFormat.zero] value. /// @@ -76,11 +51,9 @@ abstract final class Pixels with Buffer { /// ```dart /// final pixels = IntPixels(2, 2); /// pixels.clear(); - /// pixels.clear(target: Rect.fromLTWH(1, 0, 1, 2)); + /// pixels.clear(Rect.fromLTWH(1, 0, 1, 2)); /// ``` - void clear({Rect? target}) { - fill(format.zero, target: target); - } + void clear([Rect? target]); /// Clears the buffer to the [PixelFormat.zero] value. /// @@ -96,12 +69,9 @@ abstract final class Pixels with Buffer { /// ```dart /// final pixels = IntPixels(2, 2); /// pixels.clearUnsafe(); - /// pixels.clearUnsafe(target: Rect.fromLTWH(1, 0, 1, 2)); + /// pixels.clearUnsafe(Rect.fromLTWH(1, 0, 1, 2)); /// ``` - @unsafeNoBoundsChecks - void clearUnsafe({Rect? target}) { - fillUnsafe(format.zero, target: target); - } + void clearUnsafe([Rect? target]); /// Fill the buffer with the given [pixel]. /// @@ -116,14 +86,9 @@ abstract final class Pixels with Buffer { /// ```dart /// final pixels = IntPixels(2, 2); /// pixels.fill(0xFFFFFFFF); - /// pixels.fill(0x00000000, target: Rect.fromLTWH(1, 0, 1, 2)); + /// pixels.fill(0x00000000, Rect.fromLTWH(1, 0, 1, 2)); /// ``` - void fill(T pixel, {Rect? target}) { - if (target != null) { - target = target.intersect(bounds); - } - return fillUnsafe(pixel, target: target); - } + void fill(T pixel, [Rect? target]); /// Fill the buffer with the given [pixel]. /// @@ -138,33 +103,10 @@ abstract final class Pixels with Buffer { /// ```dart /// final pixels = IntPixels(2, 2); /// pixels.fillUnsafe(0xFFFFFFFF); - /// pixels.fillUnsafe(0x00000000, target: Rect.fromLTWH(1, 0, 1, 2)); + /// pixels.fillUnsafe(0x00000000, Rect.fromLTWH(1, 0, 1, 2)); /// ``` @unsafeNoBoundsChecks - void fillUnsafe(T pixel, {Rect? target}) { - if (target == null) { - return data.fillRange( - 0, - data.length, - pixel, - ); - } - if (target.width == width) { - return data.fillRange( - target.top * width, - target.bottom * width, - pixel, - ); - } - for (var y = target.top; y < target.bottom; y++) { - final x = y * width; - data.fillRange( - x + target.left, - x + target.right, - pixel, - ); - } - } + void fillUnsafe(T pixel, [Rect? target]); /// Fill the buffer with the given [pixels]. /// @@ -181,27 +123,9 @@ abstract final class Pixels with Buffer { /// ```dart /// final pixels = IntPixels(2, 2); /// pixels.fillWith([0xFFFFFFFF, 0x00000000]); - /// pixels.fillWith([0x00000000, 0xFFFFFFFF], target: Rect.fromLTWH(1, 0, 1, 2)); + /// pixels.fillWith([0x00000000, 0xFFFFFFFF], Rect.fromLTWH(1, 0, 1, 2)); /// ``` - void fillWith( - Iterable pixels, { - Rect? target, - }) { - if (target == null) { - target = bounds; - } else { - target = target.intersect(bounds); - } - if (pixels.length < target.area) { - pixels = pixels.followedBy( - Iterable.generate( - target.area - pixels.length, - (_) => format.zero, - ), - ); - } - return fillWithUnsafe(pixels, target: target); - } + void fillFrom(Iterable pixels, [Rect? target]); /// Fill the buffer with the given [pixels]. /// @@ -221,44 +145,7 @@ abstract final class Pixels with Buffer { /// pixels.fillWithUnsafe([0x00000000, 0xFFFFFFFF], target: Rect.fromLTWH(1, 0, 1, 2)); /// ``` @unsafeNoBoundsChecks - void fillWithUnsafe( - Iterable pixels, { - Rect? target, - }) { - if (target == null) { - return data.setAll(0, pixels); - } - var skip = 0; - for (var y = target.top; y < target.bottom; y++) { - final x = y * width; - data.setRange( - x + target.left, - x + target.right, - pixels.skip(skip), - ); - skip += target.width; - } - } - - @override - Iterable getRangeUnsafe(Pos start, Pos end) { - final s = _indexAtUnsafe(start); - final e = _indexAtUnsafe(end); - return data.getRange(s, e + 1); - } - - @override - Iterable getRectUnsafe(Rect rect) { - // TODO: Consider a custom Iterable. - return Iterable.generate( - rect.height, - (y) { - final start = _indexAtUnsafe(Pos(rect.left, rect.top + y)); - final end = start + rect.width; - return data.getRange(start, end); - }, - ).expand((e) => e); - } + void fillFromUnsafe(Iterable pixels, [Rect? target]); /// Copies the pixel data from a source buffer to `this` buffer. /// @@ -293,31 +180,7 @@ abstract final class Pixels with Buffer { Buffer from, { Rect? source, Pos? target, - }) { - if (source == null) { - if (target == null) { - return copyFromUnsafe(from); - } - source = from.bounds; - } else { - source = source.intersect(from.bounds); - } - target ??= Pos.zero; - final clipped = Rect.fromTLBR( - target, - target + source.size, - ).intersect(bounds); - if (clipped.isEmpty) { - return; - } - source = Rect.fromLTWH( - source.left, - source.top, - clipped.width, - clipped.height, - ); - return copyFromUnsafe(from, source: source, target: target); - } + }); /// Copies the pixel data from a source buffer to `this` buffer. /// @@ -351,59 +214,7 @@ abstract final class Pixels with Buffer { Buffer from, { Rect? source, Pos? target, - }) { - if (from is Pixels) { - _copyFromUnsafeFast(from, source: source, target: target); - } else { - _copyFromUnsafeSlow(from, source: source, target: target); - } - } - - void _copyFromUnsafeSlow( - Buffer from, { - Rect? source, - Pos? target, - }) { - // Use the slow path if the source is not a framebuffer. - final pixels = source == null ? from.data : from.getRectUnsafe(source); - fillWithUnsafe( - pixels, - target: target == null - ? null - : Rect.fromTLBR( - target, - target + from.bounds.size - const Pos(1, 1), - ), - ); - } - - void _copyFromUnsafeFast( - Pixels from, { - Rect? source, - Pos? target, - }) { - // Use the fast path if the source is a framebuffer. - if (source == null) { - final index = target == null ? 0 : _indexAtUnsafe(target); - return data.setAll(index, from.data); - } - - // Use multiple setRange calls if the source is a framebuffer. - target ??= Pos.zero; - final src = from.data; - final dst = this.data; - var srcIdx = from._indexAtUnsafe(source.topLeft); - var dstIdx = _indexAtUnsafe(target); - for (var y = source.top; y < source.bottom; y++) { - dst.setRange( - dstIdx, - dstIdx + source.width, - src.getRange(srcIdx, srcIdx + source.width), - ); - srcIdx += from.width; - dstIdx += width; - } - } + }); /// Blits, or copies with blending, the pixel data from a source buffer to /// `this` buffer. @@ -439,31 +250,7 @@ abstract final class Pixels with Buffer { Rect? source, Pos? target, BlendMode blend = BlendMode.srcOver, - }) { - if (source == null) { - if (target == null) { - return blitUnsafe(from, blend: blend); - } - source = from.bounds; - } else { - source = source.intersect(from.bounds); - } - target ??= Pos.zero; - final clipped = Rect.fromTLBR( - target, - target + source.size, - ).intersect(bounds); - if (clipped.isEmpty) { - return; - } - source = Rect.fromLTWH( - source.left, - source.top, - clipped.width, - clipped.height, - ); - return blitUnsafe(from, source: source, target: target, blend: blend); - } + }); /// Blits, or copies with blending, the pixel data from a source buffer to /// `this` buffer. @@ -492,6 +279,184 @@ abstract final class Pixels with Buffer { /// dst.blitUnsafe(src, target: Pos(1, 1)); /// dst.blitUnsafe(src, source: Rect.fromLTWH(1, 0, 1, 2), target: Pos(1, 1)); /// ``` + void blitUnsafe( + Buffer from, { + Rect? source, + Pos? target, + BlendMode blend = BlendMode.srcOver, + }); +} + +base mixin _Pixels implements Pixels { + int _indexAtUnsafe(Pos pos) => pos.y * width + pos.x; + + @override + @unsafeNoBoundsChecks + T getUnsafe(Pos pos) => data[_indexAtUnsafe(pos)]; + + /// Raw bytes of pixel data. + /// + /// This type is exposed for operations that require direct access to the + /// underlying memory, such as [copying pixel data to a canvas][1], or + /// [transferring bytes to an isolate][2]; in most cases the other methods + /// provided by [Pixels] will be used instead. + /// + /// [1]: https://pub.dev/documentation/web/latest/web/ImageData/ImageData.html + /// [2]: https://api.dart.dev/stable/3.5.1/dart-isolate/TransferableTypedData-class.html + @override + TypedDataList get data; + + @override + void set(Pos pos, T pixel) { + if (contains(pos)) { + setUnsafe(pos, pixel); + } + } + + @unsafeNoBoundsChecks + @override + void setUnsafe(Pos pos, T pixel) { + data[_indexAtUnsafe(pos)] = pixel; + } + + @override + void clear([Rect? target]) { + target = target?.intersect(bounds); + lodim.fillRectLinear(data, format.zero, width: width, bounds: target); + } + + @override + void clearUnsafe([Rect? target]) { + lodim.fillRectLinear(data, format.zero, width: width, bounds: target); + } + + @override + void fill(T pixel, [Rect? target]) { + target = target?.intersect(bounds); + lodim.fillRectLinear(data, pixel, width: width, bounds: target); + } + + @override + void fillUnsafe(T pixel, [Rect? target]) { + lodim.fillRectLinear(data, pixel, width: width, bounds: target); + } + + @override + void fillFrom(Iterable pixels, [Rect? target]) { + if (target == null) { + target = bounds; + } else { + target = target.intersect(bounds); + } + lodim.fillRectFromLinear(data, pixels, width: width, bounds: target); + } + + @override + void fillFromUnsafe(Iterable pixels, [Rect? target]) { + lodim.fillRectFromLinear(data, pixels, width: width, bounds: target); + } + + @override + Iterable getRect(Rect rect) { + rect = rect.intersect(bounds); + return lodim.getRectLinear(data, width: width, bounds: rect); + } + + @override + Iterable getRectUnsafe(Rect rect) { + return lodim.getRectLinear(data, width: width, bounds: rect); + } + + @override + void copyFrom( + Buffer from, { + Rect? source, + Pos? target, + }) { + if (source == null) { + if (target == null) { + return copyFromUnsafe(from); + } + source = from.bounds; + } else { + source = source.intersect(from.bounds); + } + target ??= Pos.zero; + final clipped = Rect.fromTLBR( + target, + target + source.size, + ).intersect(bounds); + if (clipped.isEmpty) { + return; + } + source = Rect.fromLTWH( + source.left, + source.top, + clipped.width, + clipped.height, + ); + return copyFromUnsafe(from, source: source, target: target); + } + + @override + void copyFromUnsafe( + Buffer from, { + Rect? source, + Pos? target, + }) { + final src = from; + final dst = this; + if (src is _Pixels) { + return lodim.copyRectLinear( + src.data, + dst.data, + srcWidth: src.width, + dstWidth: dst.width, + source: source, + target: target ?? Pos.zero, + ); + } + return lodim.copyRect( + source ?? src.bounds, + src.getUnsafe, + dst.setUnsafe, + target: target ?? Pos.zero, + ); + } + + @override + void blit( + Buffer from, { + Rect? source, + Pos? target, + BlendMode blend = BlendMode.srcOver, + }) { + if (source == null) { + if (target == null) { + return blitUnsafe(from, blend: blend); + } + source = from.bounds; + } else { + source = source.intersect(from.bounds); + } + target ??= Pos.zero; + final clipped = Rect.fromTLBR( + target, + target + source.size, + ).intersect(bounds); + if (clipped.isEmpty) { + return; + } + source = Rect.fromLTWH( + source.left, + source.top, + clipped.width, + clipped.height, + ); + return blitUnsafe(from, source: source, target: target, blend: blend); + } + + @override void blitUnsafe( Buffer from, { Rect? source, @@ -514,7 +479,7 @@ abstract final class Pixels with Buffer { tRect.height, ); final fn = blend.getBlend(from.format, format); - if (from is Pixels) { + if (from is _Pixels) { _blitUnsafeFast(from, source: source, target: tRect, blend: fn); } else { _blitUnsafeSlow(from, source: source, target: tRect, blend: fn); @@ -541,7 +506,7 @@ abstract final class Pixels with Buffer { } void _blitUnsafeFast( - Pixels from, { + _Pixels from, { required T Function(S src, T dst) blend, required Rect source, required Rect target, diff --git a/lib/src/buffer/pixels_float.dart b/lib/src/buffer/pixels_float.dart index ca68639..7da254b 100644 --- a/lib/src/buffer/pixels_float.dart +++ b/lib/src/buffer/pixels_float.dart @@ -11,7 +11,7 @@ part of '../buffer.dart'; /// The default [format] is [floatRgba]. /// /// {@category Buffers} -final class Float32x4Pixels extends Pixels { +final class Float32x4Pixels extends Pixels with _Pixels { /// Creates a new buffer of multi-channel floating point pixel data. /// /// Both [width] and [height] must be greater than zero. diff --git a/lib/src/buffer/pixels_int.dart b/lib/src/buffer/pixels_int.dart index c56a3b3..e4a139e 100644 --- a/lib/src/buffer/pixels_int.dart +++ b/lib/src/buffer/pixels_int.dart @@ -8,7 +8,7 @@ part of '../buffer.dart'; /// The default [format] is [abgr8888]. /// /// {@category Buffers} -final class IntPixels extends Pixels { +final class IntPixels extends Pixels with _Pixels { /// Creates a new buffer of integer-based pixel data. /// /// Both [width] and [height] must be greater than zero. diff --git a/pubspec.yaml b/pubspec.yaml index 234d036..ce76601 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,14 +3,14 @@ name: pxl description: |- A tiny cross-platform pixel buffer and foundation for pixel-based graphics. -version: 0.1.0-alpha +version: 0.1.0-alpha+1 environment: sdk: ^3.5.0 repository: https://github.com/matanlurey/pxl.dart dependencies: - lodim: ^0.1.4 + lodim: ^0.1.6+1 meta: ^1.15.0 dev_dependencies: diff --git a/test/buffer_test.dart b/test/buffer_test.dart index ed60bac..b797dbf 100644 --- a/test/buffer_test.dart +++ b/test/buffer_test.dart @@ -197,38 +197,6 @@ void main() { }); }); - test('getRange', () { - final pixels = IntPixels( - 2, - 2, - data: Uint32List.fromList([ - abgr8888.red, - abgr8888.green, - abgr8888.blue, - abgr8888.cyan, - ]), - ); - final buffer = pixels.map((p) => p); - final range = buffer.getRange(Pos(1, 0), Pos(0, 1)); - check(range).deepEquals([abgr8888.green, abgr8888.blue]); - }); - - test('getRange out of range returns nothing', () { - final pixels = IntPixels( - 2, - 2, - data: Uint32List.fromList([ - abgr8888.red, - abgr8888.green, - abgr8888.blue, - abgr8888.cyan, - ]), - ); - final buffer = pixels.map((p) => p); - final range = buffer.getRange(Pos(1, 2), Pos(2, 1)); - check(range).isEmpty(); - }); - test('getRect', () { final pixels = IntPixels( 2, diff --git a/test/pixels_test.dart b/test/pixels_test.dart index 98edf37..d370137 100644 --- a/test/pixels_test.dart +++ b/test/pixels_test.dart @@ -189,7 +189,7 @@ void main() { test('fill (rect)', () { final pixels = IntPixels(2, 2); - pixels.fill(0xFFFFFFFF, target: Rect.fromLTWH(1, 1, 1, 1)); + pixels.fill(0xFFFFFFFF, Rect.fromLTWH(1, 1, 1, 1)); check(pixels.data).deepEquals([ 0x00000000, 0x00000000, @@ -200,7 +200,7 @@ void main() { test('fill (rect, partial, full width)', () { final pixels = IntPixels(2, 2); - pixels.fill(0xFFFFFFFF, target: Rect.fromLTWH(0, 0, 2, 1)); + pixels.fill(0xFFFFFFFF, Rect.fromLTWH(0, 0, 2, 1)); check(pixels.data).deepEquals([ 0xFFFFFFFF, 0xFFFFFFFF, @@ -211,7 +211,7 @@ void main() { test('fill (rect, partial)', () { final pixels = IntPixels(2, 2); - pixels.fill(0xFFFFFFFF, target: Rect.fromLTWH(0, 0, 1, 1)); + pixels.fill(0xFFFFFFFF, Rect.fromLTWH(0, 0, 1, 1)); check(pixels.data).deepEquals([ 0xFFFFFFFF, 0x00000000, @@ -222,7 +222,7 @@ void main() { test('fill (rect, clamped)', () { final pixels = IntPixels(2, 2); - pixels.fill(0xFFFFFFFF, target: Rect.fromLTWH(1, 1, 2, 2)); + pixels.fill(0xFFFFFFFF, Rect.fromLTWH(1, 1, 2, 2)); check(pixels.data).deepEquals([ 0x00000000, 0x00000000, @@ -288,7 +288,7 @@ void main() { ], ), ); - pixels.clear(target: Rect.fromLTWH(1, 1, 1, 1)); + pixels.clear(Rect.fromLTWH(1, 1, 1, 1)); check(pixels.data).deepEquals([ 0xFFFFFFFF, 0xFFFFFFFF, @@ -299,7 +299,7 @@ void main() { test('fillWith', () { final pixels = IntPixels(2, 2); - pixels.fillWith([0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF]); + pixels.fillFrom([0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF]); check(pixels.data).deepEquals([ 0xFFFFFFFF, 0xFFFFFFFF, @@ -310,9 +310,9 @@ void main() { test('fillWith (rect)', () { final pixels = IntPixels(2, 2); - pixels.fillWith( + pixels.fillFrom( [0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF], - target: Rect.fromLTWH(1, 1, 1, 1), + Rect.fromLTWH(1, 1, 1, 1), ); check(pixels.data).deepEquals([ 0x00000000, @@ -324,9 +324,9 @@ void main() { test('fillWith (rect, partial)', () { final pixels = IntPixels(2, 2); - pixels.fillWith( + pixels.fillFrom( [0xFFFFFFFF, 0xFFFFFFFF], - target: Rect.fromLTWH(0, 0, 1, 1), + Rect.fromLTWH(0, 0, 1, 1), ); check(pixels.data).deepEquals([ 0xFFFFFFFF, @@ -338,9 +338,9 @@ void main() { test('fillWith (rect, clamped)', () { final pixels = IntPixels(2, 2); - pixels.fillWith( + pixels.fillFrom( [0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF], - target: Rect.fromLTWH(1, 1, 2, 2), + Rect.fromLTWH(1, 1, 2, 2), ); check(pixels.data).deepEquals([ 0x00000000, @@ -352,9 +352,9 @@ void main() { test('fillWith (rect, insufficient data)', () { final pixels = IntPixels(2, 2); - pixels.fillWith( + pixels.fillFrom( [0xFFFFFFFF], - target: Rect.fromLTWH(0, 0, 2, 2), + Rect.fromLTWH(0, 0, 2, 2), ); check(pixels.data).deepEquals([ 0xFFFFFFFF, @@ -366,9 +366,9 @@ void main() { test('fillWith (rect, too much data)', () { final pixels = IntPixels(2, 2); - pixels.fillWith( + pixels.fillFrom( [0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF], - target: Rect.fromLTWH(1, 1, 1, 1), + Rect.fromLTWH(1, 1, 1, 1), ); check(pixels.data).deepEquals([ 0x00000000, @@ -378,21 +378,6 @@ void main() { ]); }); - test('getRange', () { - final pixels = IntPixels( - 2, - 2, - data: Uint32List.fromList([ - abgr8888.red, - abgr8888.green, - abgr8888.blue, - abgr8888.cyan, - ]), - ); - final range = pixels.getRange(Pos(1, 0), Pos(0, 1)); - check(range).deepEquals([abgr8888.green, abgr8888.blue]); - }); - group('getRectUnsafe', () { test('full', () { final pixels = IntPixels(