From bf93b4c4699a7d497886660090a0e958ab811550 Mon Sep 17 00:00:00 2001 From: Marcus Lundblad Date: Sun, 4 Dec 2022 22:41:56 +0100 Subject: [PATCH] userLocationMarker: Rotate around center of icon 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. --- src/userLocationMarker.js | 8 ++++++++ 1 file changed, 8 insertions(+) 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); -- GitLab