Skip to content

Commit

Permalink
Invert position again to be normal
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Feb 9, 2024
1 parent fea7343 commit dfada58
Show file tree
Hide file tree
Showing 13 changed files with 347 additions and 334 deletions.
5 changes: 5 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ Older versions can be found [here](https://docs.butterfly.linwood.dev/pre-1-0).

Please use [the bug tracker](https://github.com/LinwoodDev/butterfly/issues) or use [[email protected]](mailto:[email protected]) if there is a critical bug.

## Version scheme

The version scheme is based on [Semantic Versioning](https://semver.org/spec/v2.0.0.html). All stable versions will be released in stable branch while all alpha, beta and release candidates will be released in the nightly branch.
There will be alphas, betas and release candidates on every major release, betas and release candidates on every minor release and release candidates on every patch release.

## Branches

| Name | Support | Description | Tag |
Expand Down
4 changes: 2 additions & 2 deletions app/lib/actions/image_export.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class ImageExportAction extends Action<ImageExportIntent> {
child: ImageExportDialog(
width: size.width,
height: size.height,
x: -transform.position.dx,
y: -transform.position.dy,
x: transform.position.dx,
y: transform.position.dy,
scale: transform.size,
),
),
Expand Down
4 changes: 2 additions & 2 deletions app/lib/actions/svg_export.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class SvgExportAction extends Action<SvgExportIntent> {
child: SvgExportDialog(
width: (size.width / scale).round(),
height: (size.height / scale).round(),
x: -transform.position.dx,
y: -transform.position.dy,
x: transform.position.dx,
y: transform.position.dy,
),
),
context: intent.context);
Expand Down
4 changes: 2 additions & 2 deletions app/lib/cubits/current_index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ class CurrentIndexCubit extends Cubit<CurrentIndex> {
return;
}
final transform = state.transformCubit.state;
final rect = Rect.fromLTWH(-transform.position.dx, -transform.position.dy,
final rect = Rect.fromLTWH(transform.position.dx, transform.position.dy,
size.width / transform.size, size.height / transform.size);
var renderers =
List<Renderer<PadElement>>.from(cameraViewport.unbakedElements);
Expand Down Expand Up @@ -774,7 +774,7 @@ class CurrentIndexCubit extends Cubit<CurrentIndex> {
if (delta.dx == 0 && delta.dy == 0) {
return;
}
state.transformCubit.move(delta);
state.transformCubit.move(-delta);
}

void zoom(double delta, [Offset cursor = Offset.zero, bool force = false]) {
Expand Down
10 changes: 5 additions & 5 deletions app/lib/cubits/transform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ class CameraTransform extends Equatable {
// Set size and focus on cursor if provided
final double newSize = size.clamp(kMinZoom, kMaxZoom);
var mx = localToGlobal(cursor);
mx = (mx + position) * newSize;
mx = (mx - position) * newSize;

return CameraTransform(
position + (cursor - mx) / newSize,
position + (mx - cursor) / newSize,
newSize,
);
}

Offset localToGlobal(Offset local) => local / size - position;
Offset globalToLocal(Offset global) => (global + position) * size;
Offset localToGlobal(Offset local) => local / size + position;
Offset globalToLocal(Offset global) => (global - position) * size;

@override
List<Object?> get props => [position, size];
Expand All @@ -59,6 +59,6 @@ class TransformCubit extends Cubit<CameraTransform> {
emit(state.withSize(size, cursor));

void moveToWaypoint(Waypoint waypoint) => emit(state
.withPointPosition(-waypoint.position)
.withPointPosition(waypoint.position)
.withSize(waypoint.scale ?? state.size));
}
2 changes: 1 addition & 1 deletion app/lib/models/viewport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class CameraViewport extends Equatable {

Area toArea() => Area(
name: '',
position: -toPoint(),
position: toPoint(),
width: (width?.toDouble() ?? 0) / scale,
height: (height?.toDouble() ?? 0) / scale,
);
Expand Down
8 changes: 4 additions & 4 deletions app/lib/renderers/textures/pattern.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ void drawPatternTextureOnCanvas(PatternTexture texture, Canvas canvas,
var relativeSpace = texture.boxXSpace * scale;
final part = texture.boxWidth * texture.boxXCount + texture.boxXSpace;
int xCount = (offset.dx / part).floor();
if (extraLines) xCount++;
double x = -xCount * part + offset.dx;
if (extraLines) xCount--;
double x = xCount * part - offset.dx;
x *= scale;

int count = 0;
Expand All @@ -38,8 +38,8 @@ void drawPatternTextureOnCanvas(PatternTexture texture, Canvas canvas,
var relativeSpace = texture.boxYSpace * scale;
final part = texture.boxHeight * texture.boxYCount + texture.boxYSpace;
int yCount = (offset.dy / part).floor();
if (extraLines) yCount++;
double y = -yCount * part + offset.dy;
if (extraLines) yCount--;
double y = yCount * part + -offset.dy;
y *= scale;
int count = 0;
while (y < size.height) {
Expand Down
6 changes: 3 additions & 3 deletions app/lib/renderers/utilities.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class UtilitiesRenderer extends Renderer<UtilitiesState> {
while (y < size.height) {
final localY = y / transform.size;
canvas.drawLine(
Offset(-transform.position.dx, -transform.position.dy + localY),
Offset(-transform.position.dx + size.width / transform.size,
-transform.position.dy + localY),
Offset(transform.position.dx, transform.position.dy + localY),
Offset(transform.position.dx + size.width / transform.size,
transform.position.dy + localY),
Paint()
..strokeWidth = 1 / transform.size
..color = Color(option.gridColor),
Expand Down
10 changes: 5 additions & 5 deletions app/lib/view_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ForegroundPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
canvas.scale(transform.size);
canvas.translate(transform.position.dx, transform.position.dy);
canvas.translate(-transform.position.dx, -transform.position.dy);
for (var renderer in renderers) {
final center = renderer.rect?.center;
final radian = renderer.rotation * (pi / 180);
Expand Down Expand Up @@ -137,10 +137,10 @@ class ViewPainter extends CustomPainter {
}
}
if (cameraViewport.bakedElements.isNotEmpty && renderBaked) {
var image = cameraViewport.image;
var bakedSizeDiff =
final image = cameraViewport.image;
final bakedSizeDiff =
(transform.size - cameraViewport.scale) / cameraViewport.scale;
var pos = transform.globalToLocal(-cameraViewport.toOffset());
final pos = transform.globalToLocal(cameraViewport.toOffset());

// Draw our baked image, scaling it down with drawImageRect.
if (image != null) {
Expand All @@ -153,7 +153,7 @@ class ViewPainter extends CustomPainter {
}
}
canvas.scale(transform.size, transform.size);
canvas.translate(transform.position.dx, transform.position.dy);
canvas.translate(-transform.position.dx, -transform.position.dy);
for (final renderer in cameraViewport.unbakedElements) {
final state = states[renderer];
if (!invisibleLayers.contains(renderer.element.layer) &&
Expand Down
16 changes: 8 additions & 8 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ packages:
dependency: transitive
description:
name: camera_avfoundation
sha256: "608b56b0880722f703871329c4d7d4c2f379c8e2936940851df7fc041abc6f51"
sha256: "7d0763dfcbf060f56aa254a68c103210280bee9e97bbe4fdef23e257a4f70ab9"
url: "https://pub.dev"
source: hosted
version: "0.9.13+10"
version: "0.9.14"
camera_platform_interface:
dependency: transitive
description:
Expand Down Expand Up @@ -643,10 +643,10 @@ packages:
dependency: "direct main"
description:
name: go_router
sha256: "07ee2436909f749d606f53521dc1725dd738dc5196e5ff815bc254253c594075"
sha256: "170c46e237d6eb0e6e9f0e8b3f56101e14fb64f787016e42edd74c39cf8b176a"
url: "https://pub.dev"
source: hosted
version: "13.1.0"
version: "13.2.0"
graphs:
dependency: transitive
description:
Expand Down Expand Up @@ -1009,10 +1009,10 @@ packages:
dependency: "direct main"
description:
name: popover
sha256: "6a0928ccdcf12d46b407372b644a0d94400b316d0ee072a19dcef03c2bb88c3f"
sha256: ca3bef9d88ebf5c5c3823946a5de3ce8360018fbb6a3e25819586a7d5a203db2
url: "https://pub.dev"
source: hosted
version: "0.2.9"
version: "0.3.0"
printing:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1499,5 +1499,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.2.0 <4.0.0"
flutter: ">=3.16.0"
dart: ">=3.2.3 <4.0.0"
flutter: ">=3.16.6"
4 changes: 2 additions & 2 deletions app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies:
share_plus: ^7.2.2
package_info_plus: ^5.0.1
idb_shim: ^2.3.2
go_router: ^13.1.0
go_router: ^13.2.0
xml: ^6.5.0
collection: ^1.18.0
bloc_concurrency: ^0.2.3
Expand Down Expand Up @@ -89,7 +89,7 @@ dependencies:
path: packages/networker/networker_socket
flutter_localized_locales: ^2.0.5
dynamic_color: ^1.6.9
popover: ^0.2.9
popover: ^0.3.0
markdown: ^7.2.1
device_info_plus: ^9.1.2
image: ^4.1.6
Expand Down
Loading

0 comments on commit dfada58

Please sign in to comment.