Skip to content

Commit

Permalink
Added Ability to Rotate Field (#166)
Browse files Browse the repository at this point in the history
* Improved math behind field object position calculation (center origin)
* Ability to rotate field
  • Loading branch information
Gold872 authored Dec 31, 2024
1 parent a930e58 commit 50c2881
Show file tree
Hide file tree
Showing 7 changed files with 312 additions and 205 deletions.
11 changes: 10 additions & 1 deletion lib/services/field_images.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,22 @@ class Field {
int? fieldImageWidth;
int? fieldImageHeight;

Size? get fieldImageSize =>
(fieldImageWidth != null && fieldImageHeight != null)
? Size(fieldImageWidth!.toDouble(), fieldImageHeight!.toDouble())
: null;

late double fieldWidthMeters;
late double fieldHeightMeters;

late Offset topLeftCorner;
late Offset bottomRightCorner;

late Offset fieldCenter;
Offset get center => (fieldImageLoaded)
? Offset(bottomRightCorner.dx - topLeftCorner.dx,
bottomRightCorner.dy - topLeftCorner.dy) /
2
: const Offset(0, 0);

late Image fieldImage;

Expand Down
4 changes: 2 additions & 2 deletions lib/services/nt_widget_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ class NTWidgetBuilder {
model: FieldWidgetModel.new,
widget: FieldWidget.new,
fromJson: FieldWidgetModel.fromJson,
minWidth: _normalSize * 3,
minWidth: _normalSize * 2,
minHeight: _normalSize * 2,
defaultWidth: 3,
defaultWidth: 2,
defaultHeight: 2);

register(
Expand Down
Loading

0 comments on commit 50c2881

Please sign in to comment.