From 91c93d637ec7eb3b2d9a5f4f2d3685f0248f8eda Mon Sep 17 00:00:00 2001 From: Jared Wahlstrand Date: Sun, 26 May 2024 08:17:39 -0400 Subject: [PATCH] annotations: widen the user bounding box by half a pixel on all sides (#305) When drawing anchored annotations, widen the user bounding box since the pixels are centered on the integers of the user coordinates. Fixes #223. --- src/annotations.jl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/annotations.jl b/src/annotations.jl index 974ad16..13c0615 100644 --- a/src/annotations.jl +++ b/src/annotations.jl @@ -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