Skip to content

Commit

Permalink
Fix baking not working correctly when zooming in
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Dec 17, 2024
1 parent 1639801 commit e8c44f5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
10 changes: 4 additions & 6 deletions app/lib/cubits/current_index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -523,14 +523,15 @@ class CurrentIndexCubit extends Cubit<CurrentIndex> {
if (viewportSize != null) {
size *= resolution.multiplier;
}
final renderTransform =
transform.improve(resolution, size / resolution.multiplier);
final imageWidth = (size.width * ratio).ceil();
final imageHeight = (size.height * ratio).ceil();
rect = resolution.getRect(rect);
final renderTransform = transform.improve(resolution, rect.size);
final viewChanged = cameraViewport.width != size.width.ceil() ||
cameraViewport.height != size.height.ceil() ||
cameraViewport.x != renderTransform.position.dx ||
cameraViewport.y != renderTransform.position.dy ||
cameraViewport.scale != transform.size;
rect = resolution.getRect(rect);
reset = reset || viewChanged;
resetAllLayers = resetAllLayers || viewChanged;
if (renderers.isEmpty && !reset) return;
Expand Down Expand Up @@ -571,9 +572,6 @@ class CurrentIndexCubit extends Cubit<CurrentIndex> {

var picture = recorder.endRecording();

final imageWidth = (size.width * ratio).ceil();
final imageHeight = (size.height * ratio).ceil();

final newImage = await picture.toImage(imageWidth, imageHeight);

var currentRenderers = state.cameraViewport.unbakedElements;
Expand Down
4 changes: 0 additions & 4 deletions app/lib/models/viewport.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:math';
import 'dart:ui' as ui;

import 'package:butterfly/cubits/settings.dart';
import 'package:butterfly/renderers/renderer.dart';
import 'package:butterfly_api/butterfly_api.dart';
import 'package:equatable/equatable.dart';
Expand Down Expand Up @@ -63,9 +62,6 @@ class CameraViewport extends Equatable {

ui.Rect toRect() => toOffset() & toSize(true);

ui.Rect toViewportRect(RenderResolution resolution) =>
resolution.getRect(toOffset() & toSize(true));

Area toArea() => Area(
name: '',
position: toPoint(),
Expand Down
3 changes: 2 additions & 1 deletion metadata/en-US/changelogs/125.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* Improve mobile color picker
* Improve mobile color picker
* Fix baking not working correctly when zooming in

0 comments on commit e8c44f5

Please sign in to comment.