Anti-aliased line/circle rendering and grayscale PNG output - #22
Open
Grizaster wants to merge 1 commit into
Open
Anti-aliased line/circle rendering and grayscale PNG output#22Grizaster wants to merge 1 commit into
Grizaster wants to merge 1 commit into
Conversation
Rendering improvements: - Thin diagonal lines (^GD t≤1): replace Bresenham with Xiaolin Wu's algorithm (draw_antialiased_line_segment_mut) for smooth edges - Thick diagonal lines (^GD t>1): custom parallelogram fill with per-pixel coverage at left/right edges - Circles (^GC): per-pixel distance-based coverage for both inner and outer ring edges, producing smooth anti-aliased edges - PNG output: remove binary threshold, output 8-bit grayscale to preserve anti-aliasing (matches Labelary default Grayscale quality) Tests: - Update unit_png_encoder tests for grayscale passthrough - Increase dhlparceluk golden test tolerance (5.5% → 6.0%) - Regenerate all testdata/diffs
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.
Overview
This PR improves rendering quality by adding anti-aliasing for all line and circle primitives, and switches PNG output from 1-bit monochrome to 8-bit grayscale (matching Labelary's default
X-Quality: Grayscaleoutput).Rendering Improvements
Anti-aliased diagonal lines (
^GD)draw_line_segment_mut) with Xiaolin Wu's algorithm (draw_antialiased_line_segment_mut) for smooth edgesdraw_polygon_mutapproach only drew the outline, not the filled shapeAnti-aliased circles (
^GC)draw_filled_circle_mutand the binary distance-check ring with a per-pixel coverage-based approachGrayscale PNG output
pixel > 128 ? 255 : 0) fromencode_pngX-Quality: GrayscaleoutputTests
unit_png_encodertests: assert grayscale passthrough instead of binary threshold behaviormanual_clampwarnings: useclamp()instead ofmax().min()dhlparcelukgolden test tolerance from 5.5% to 6.0% (5.57% diff due to anti-aliasing)testdata/diffs/after rendering changesFiles Changed
src/drawers/renderer.rs— anti-aliased line and circle renderingsrc/images/monochrome.rs— grayscale PNG encoding (removed binary threshold)tests/unit_png_encoder.rs— updated teststests/e2e_golden.rs— tolerance adjustmentdocs/DIFF_THRESHOLDS.md— updated tolerancetestdata/diffs/*— regenerated diff images and reports