Skip to content

Commit

Permalink
calculate margin per pixel individually
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Freudenberg committed Feb 12, 2024
1 parent b0798f8 commit def0bbb
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions CairoMakie/src/primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -772,20 +772,21 @@ function draw_atomic(scene::Scene, screen::Screen, @nospecialize(primitive::Unio
end

function _draw_rect_heatmap(ctx, xys, ni, nj, colors, margin_factor=0.05f0)
# dx and dy are the margin widths that are added to the
# heatmap cell sizes further down
# adding 5% seems like a good compromise between avoiding artifacts
# and not changing pixel sizes too much
# how much is added can be controlled via margin_factor

dx = abs(xys[2,1][1] - xys[1,1][1]) * 0.5f0 * margin_factor
dy = abs(xys[1,2][2] - xys[1,1][2]) * 0.5f0 * margin_factor
@inbounds for i in 1:ni, j in 1:nj
p1 = xys[i, j]
p2 = xys[i+1, j]
p3 = xys[i+1, j+1]
p4 = xys[i, j+1]

# dx and dy are the margin widths that are added to the
# heatmap cell sizes further down
# adding 5% seems like a good compromise between avoiding artifacts
# and not changing pixel sizes too much
# how much is added can be controlled via margin_factor

dx = abs(p2[1] - p1[1]) * 0.5f0 * margin_factor
dy = abs(p4[2] - p1[2]) * 0.5f0 * margin_factor

# Rectangles and polygons that are directly adjacent usually show
# white lines between them due to anti aliasing. To avoid this we
# increase their size slightly.
Expand Down

0 comments on commit def0bbb

Please sign in to comment.