Skip to content

Commit

Permalink
AtlasEngine: Curly line redux (#17508)
Browse files Browse the repository at this point in the history
See #17501.

(cherry picked from commit 7f2249c)
Service-Card-Id: 92942980
Service-Version: 1.21
  • Loading branch information
lhecker authored and DHowett committed Aug 13, 2024
1 parent 09aa541 commit 5a99621
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/renderer/atlas/BackendD2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,24 +658,14 @@ void BackendD2D::_drawGridlineRow(const RenderingPayload& p, const ShapedRow* ro
// it being simple to implement and robust against more peculiar fonts with unusually large/small descenders, etc.
// We still need to ensure though that it doesn't clip out of the cellHeight at the bottom, which is why `position` has a min().
const auto height = std::max(3.0f, duBottom + duHeight - duTop);
const auto position = std::min(duTop, cellHeight - height - duHeight);
const auto position = std::min(duTop, cellHeight - height);

// The amplitude of the wave needs to account for the stroke width, so that the final height including
// antialiasing isn't larger than our target `height`. That's why we calculate `(height - duHeight)`.
//
// In other words, Direct2D draws strokes centered on the path. This also means that (for instance)
// for a line width of 1px, we need to ensure that the amplitude passes through the center of a pixel.
// Because once the path gets stroked, it'll occupy half a pixel on either side of the path.
// This results in a "crisp" look. That's why we do `round(amp + half) - half`.
const auto halfLineWidth = 0.5f * duHeight;
const auto amplitude = roundf((height - duHeight) * 0.5f + halfLineWidth) - halfLineWidth;
// While the amplitude needs to account for the stroke width, the vertical center of the wave needs
// to be at an integer pixel position of course. Otherwise, the wave won't be vertically symmetric.
const auto center = cellCenter + position + amplitude + halfLineWidth;

const auto top = center - 2.0f * amplitude;
const auto bottom = center + 2.0f * amplitude;
const auto step = 0.5f * height;
const auto center = cellCenter + position + 0.5f * height;
const auto top = center - (height - duHeight);
const auto bottom = center + (height - duHeight);
const auto step = roundf(0.5f * height);
const auto period = 4.0f * step;

const auto from = r.from * scaledCellWidth;
Expand Down

0 comments on commit 5a99621

Please sign in to comment.