diff options
author | Marcus Lundblad <ml@dfupdate.se> | 2022-12-04 22:41:56 +0100 |
---|---|---|
committer | Marcus Lundblad <ml@dfupdate.se> | 2022-12-04 22:41:56 +0100 |
commit | bf93b4c4699a7d497886660090a0e958ab811550 (patch) | |
tree | a5d910989cee5fbf11ea08e8d9acee8555d17a61 | |
parent | 3fc02a859bab072d92f37bc6936d10a101cdf219 (diff) | |
download | gnome-maps-wip/mlundblad/fix-compass-rotation.tar.gz |
userLocationMarker: Rotate around center of iconwip/mlundblad/fix-compass-rotation
When there's a location heading (showing the compass location
icon), apply appropriate translation transforms when rotating
to get rotation around the icon's center point.
-rw-r--r-- | src/userLocationMarker.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/userLocationMarker.js b/src/userLocationMarker.js index 173b296b..26fcc8d4 100644 --- a/src/userLocationMarker.js +++ b/src/userLocationMarker.js @@ -130,7 +130,15 @@ export class UserLocationMarker extends MapMarker { vfunc_snapshot(snapshot) { if (this.place.location.heading > -1) { + // rotate around the center of the icon + let {x, y, width, height} = this.get_allocation(); + let point = new Graphene.Point(); + + point.init(width / 2, height / 2); + snapshot.translate(point); snapshot.rotate(this.place.location.heading); + point.init(-width / 2, -height / 2); + snapshot.translate(point); } this.snapshot_child(this._image, snapshot); |