Initial commit
Some checks failed
Main Deploy Workflow / deploy_web (push) Has been cancelled
Main Deploy Workflow / deploy_playstore_internal (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled

This commit is contained in:
2026-09-11 15:59:56 -03:00
commit 0037b0b9cf
651 changed files with 199705 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
// SPDX-FileCopyrightText: 2019-Present Christian Kußowski
// SPDX-FileCopyrightText: 2019-Present Contributors to FluffyChat
//
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'dart:ui';
import 'package:crop_image/crop_image.dart';
/// Pure coordinate/rotation helpers for the image editor in
/// `send_file_dialog.dart`. Kept dependency-free (only `dart:ui` and
/// `crop_image`) so they can be unit-tested without spinning up the app.
/// Maps a quarter-turn count (positive = clockwise) to the [CropRotation] used
/// when baking the final image, so the on-screen `RotatedBox` preview and the
/// saved result always rotate the same way.
CropRotation imageEditorRotationForQuarterTurns(int quarterTurns) {
switch (((quarterTurns % 4) + 4) % 4) {
case 1:
return CropRotation.right;
case 2:
return CropRotation.down;
case 3:
return CropRotation.left;
default:
return CropRotation.up;
}
}
/// Maps a pointer position on the draw surface (logical pixels) to a coordinate
/// in the source image's pixel space, given the currently shown crop region
/// [cropPx] displayed at [displaySize]. The mapping is a uniform scale plus
/// translation because the draw surface preserves the crop's aspect ratio.
Offset imageEditorLocalToImagePx(Offset local, Size displaySize, Rect cropPx) {
final scale = cropPx.width / displaySize.width;
return Offset(cropPx.left + local.dx * scale, cropPx.top + local.dy * scale);
}