Skip to content

Commit

Permalink
Minor bux fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
vlidholt committed Sep 23, 2022
1 parent da7453f commit 12c0018
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
20 changes: 17 additions & 3 deletions lib/src/editable_pixel_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,31 @@ class PixelImageController extends ValueNotifier<_PixelImageValue> {

set pixels(ByteData pixels) {
assert(pixels.lengthInBytes == width * height);
_pixelBytes = pixels.buffer.asUint8List();
_update();
}

/// Sets a specific pixel in teh [EditablePixelImage] controlled by the
/// Sets a specific pixel in the [EditablePixelImage] controlled by the
/// controller.
void setPixel({
required int pixel,
required int colorIndex,
required int x,
required int y,
}) {
_pixelBytes[y * width + x] = pixel;
setPixelIndex(
pixelIndex: y * width + x,
colorIndex: colorIndex,
);
_update();
}

/// Sets a specific pixel in the [EditablePixelImage] controlled by the
/// controller.
void setPixelIndex({
required pixelIndex,
required colorIndex,
}) {
_pixelBytes[pixelIndex] = colorIndex;
_update();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/pixel_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class _PixelEditorState extends State<PixelEditor> {
controller: widget.controller,
onTappedPixel: (details) {
widget.controller.setPixel(
pixel: _selectedColor,
colorIndex: _selectedColor,
x: details.x,
y: details.y,
);
Expand Down
6 changes: 3 additions & 3 deletions lib/src/pixel_palette.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ class PixelPalette {
/// A [PixelPalette] with the colors used by r/place.
const PixelPalette.rPlace()
: colors = const [
Color(0xFFFFFFFF),
Color(0xFFE4E4E4),
Color(0xFF888888),
Color(0xFF222222),
Color(0xFF888888),
Color(0xFFE4E4E4),
Color(0xFFFFFFFF),
Color(0xFFFFA7D1),
Color(0xFFE50000),
Color(0xFFE59500),
Expand Down

0 comments on commit 12c0018

Please sign in to comment.