Skip to content

Commit

Permalink
annotations: widen the user bounding box by half a pixel on all sides (
Browse files Browse the repository at this point in the history
…#305)

When drawing anchored annotations, widen the user bounding box since the pixels are centered on the integers of the user coordinates.

Fixes #223.
  • Loading branch information
jwahlstrand authored May 26, 2024
1 parent 5b7b264 commit 91c93d6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/annotations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,11 @@ function Gtk4.draw(c::Gtk4.GtkCanvas, ann::AnchoredAnnotation)
ctx = getgc(c)
Graphics.save(ctx)
data = ann.data
set_coordinates(ctx, ann.devicebb(data), ann.userbb(data))
scale_x = width(ann.userbb(data))/width(ann.devicebb(data))
scale_y = height(ann.userbb(data))/height(ann.devicebb(data))
userbb = BoundingBox(ann.userbb(data).xmin-0.5,ann.userbb(data).xmax+0.5,ann.userbb(data).ymin-0.5,ann.userbb(data).ymax+0.5)
devicebb = ann.devicebb(data)
set_coordinates(ctx, ann.devicebb(data), userbb)
scale_x = width(userbb)/width(devicebb)
scale_y = height(userbb)/height(devicebb)
draw_anchored(ctx, data, scale_x, scale_y)
restore(ctx)
end
Expand Down

0 comments on commit 91c93d6

Please sign in to comment.