Skip to content

Commit

Permalink
feat: add static Marker.computePixelAlignment method to calculate a…
Browse files Browse the repository at this point in the history
…bsolute alignment (#1847)
  • Loading branch information
monsieurtanuki authored Mar 12, 2024
1 parent a36c59a commit bf70478
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/src/layer/marker_layer/marker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ part of 'marker_layer.dart';
///
/// Some properties defaults will absorb the values from the parent
/// [MarkerLayer], if the reflected properties are defined there.
/// [alignment] may be computed using [computePixelAlignment].
@immutable
class Marker {
/// Provide an optional [Key] for the [Marker].
Expand Down Expand Up @@ -61,4 +62,16 @@ class Marker {
this.alignment,
this.rotate,
});

/// Returns the alignment of a [width]x[height] rectangle by [left]x[top] pixels.
static Alignment computePixelAlignment({
required final double width,
required final double height,
required final double left,
required final double top,
}) =>
Alignment(
1.0 - 2 * left / width,
1.0 - 2 * top / height,
);
}

0 comments on commit bf70478

Please sign in to comment.