Kruptein / PlanarAlly

A companion tool for when you travel into the planes.
https://www.planarally.io/
MIT License
393 stars 70 forks source link

bug(Note): Fix note position when drawn on shape #1418

Closed Kruptein closed 3 months ago

Kruptein commented 3 months ago

This fixes #1408

As mentioned in the ticket, the position of the note icon on the map is pretty random if your shape is not a nice 1x1. It was using a hardcoded (0, -30) vector compared to the refPoint of the related shape, which makes little sense if the shape starts having bigger dimensions.

The current fix is to always render using the bounding box bottom left corner of the shape and by applying a scaling factor based on the same bbox to adjust the size of the note icon based on the size of the related shape. This functions similarly to what badges currently do.

This allows it to work decently with rectangles and circles. It's still pretty wonky for polygons and text shapes, but I'm honestly not sure if there really is a decent use case for attaching a note with a specific icon to these shapes.