Skip to content

Commit 9a7dfd7

Browse files
committed
Merge pull request #5603 from mdboom/circle-marker-snapping
FIX: Draw markers around center of pixels
2 parents befb2ca + 31e6a73 commit 9a7dfd7

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

src/_backend_agg.h

+8
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ inline void RendererAgg::draw_markers(GCAgg &gc,
516516

517517
// Deal with the difference in y-axis direction
518518
marker_trans *= agg::trans_affine_scaling(1.0, -1.0);
519+
519520
trans *= agg::trans_affine_scaling(1.0, -1.0);
520521
trans *= agg::trans_affine_translation(0.5, (double)height + 0.5);
521522

@@ -527,6 +528,13 @@ inline void RendererAgg::draw_markers(GCAgg &gc,
527528
points_to_pixels(gc.linewidth));
528529
curve_t marker_path_curve(marker_path_snapped);
529530

531+
if (!marker_path_snapped.is_snapping()) {
532+
// If the path snapper isn't in effect, at least make sure the marker
533+
// at (0, 0) is in the center of a pixel. This, importantly, makes
534+
// the circle markers look centered around the point they refer to.
535+
marker_trans *= agg::trans_affine_translation(0.5, 0.5);
536+
}
537+
530538
transformed_path_t path_transformed(path, trans);
531539
nan_removed_t path_nan_removed(path_transformed, false, false);
532540
snap_t path_snapped(path_nan_removed, SNAP_FALSE, path.total_vertices(), 0.0);

0 commit comments

Comments
 (0)