Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions packages/flame_tiled/lib/src/renderable_layers/image_layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class FlameImageLayer extends RenderableLayer<ImageLayer> {
final Image _image;
late final ImageRepeat _repeat;
final MutableRect _paintArea = MutableRect.fromLTRB(0, 0, 0, 0);
final Vector2 _canvasSize = Vector2.zero();
final Vector2 _maxTranslation = Vector2.zero();

FlameImageLayer({
Expand All @@ -29,9 +28,7 @@ class FlameImageLayer extends RenderableLayer<ImageLayer> {
}

@override
void handleResize(Vector2 canvasSize) {
_canvasSize.setFrom(canvasSize);
}
void handleResize(Vector2 canvasSize) {}

@override
void render(Canvas canvas, CameraComponent? camera) {
Expand Down Expand Up @@ -81,18 +78,18 @@ class FlameImageLayer extends RenderableLayer<ImageLayer> {
if (_repeat == ImageRepeat.repeatX || _repeat == ImageRepeat.repeat) {
final xImages = (_maxTranslation.x / _image.size.x).ceil();
_paintArea.left = -_image.size.x * xImages;
_paintArea.right = _canvasSize.x + _image.size.x * xImages;
_paintArea.right = _image.size.x * xImages;
} else {
_paintArea.left = 0;
_paintArea.right = _canvasSize.x;
_paintArea.right = _image.size.x;
}
if (_repeat == ImageRepeat.repeatY || _repeat == ImageRepeat.repeat) {
final yImages = (_maxTranslation.y / _image.size.y).ceil();
_paintArea.top = -_image.size.y * yImages;
_paintArea.bottom = _canvasSize.y + _image.size.y * yImages;
_paintArea.bottom = _image.size.y * yImages;
} else {
_paintArea.top = 0;
_paintArea.bottom = _canvasSize.y;
_paintArea.bottom = _image.size.y;
}
}

Expand Down