Repository navigation
Make the blur an actual blur - #2
Merged
Merged
Conversation
`style: 'blur'` was a twelvefold downscale drawn back up with bilinear smoothing. That reads as a blocky smear rather than a blur, and the letter shapes stay faintly guessable in it. Now it downsamples first and then runs a real gaussian pass over the region. The two steps do different jobs and it is worth keeping them separate: the downsample is the one that destroys the detail, because at a twelfth of the size there is no glyph left to sharpen back up, and the gaussian is cosmetic. The blur reads a padded region rather than the box alone. Blurring the box on its own samples transparency past its edges, which leaves a pale halo just inside the border and makes the box look like a sticker. Only the box itself is written back. Radius is tied to the height of what is covered, so a page rendered at 300 dpi gets the same apparent softness as one at 150. `pixelate` keeps the same downsample with smoothing off, which is what it always wanted to be, and the shared step is now one function. The warning was wrong, so it is rewritten. It said blurred text "can often be recovered", which is not true of a twelvefold downsample. What these two styles actually leak is the shape of what was covered: how many words, how long each was, and where the lines broke. That is enough to tell a short name from a long one, which is a real reason to prefer `box`, just not the reason the warning gave. Signed-off-by: Govind Pandey <govindup63@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
style: 'blur'was a twelvefold downscale drawn back up with bilinear smoothing. That reads as a blocky smear rather than a blur, and the letter shapes stay faintly guessable in it.What changed
Downsample first, then a real gaussian pass over the region. Keeping the two steps separate matters, because they do different jobs:
The blur reads a padded region rather than the box alone. Blurring the box on its own samples transparency past its edges, which leaves a pale halo just inside the border and makes the box look like a sticker. Only the box itself is written back; the padding is scaffolding.
Radius is tied to the height of what is being covered (
box.height * 0.32, floor 3 px), so a page rendered at 300 dpi gets the same apparent softness as one at 150. No new option: the sensible radius is a function of the text size, not something a caller should have to guess.pixelatekeeps the same downsample with smoothing off, which is what it always wanted to be. The shared step is now onedownsample()helper.The warning was wrong
It said blurred and pixelated text "can often be recovered". That is not true of a twelvefold downsample, so the warning was overstating one risk and hiding the real one.
What these two styles actually leak is the shape of what was covered: how many words there were, how long each one was, and where the lines broke. That is enough to tell a short name from a long one, which is a genuine reason to prefer
boxwhen the output leaves your control. The warning and the README now say that instead.Verified
Rendered all four styles on the test fixture at 150 dpi and compared against the previous implementation. The new blur is an even, soft band with no readable letter shapes and no edge halo;
pixelatestays visibly distinct from it. Tests 13/13,typecheckclean.Docs: the
stylenote and the throws-and-warns table in the README are updated to match.