Skip to content

Commit

Permalink
Merge pull request rust-windowing#232 from s3bk/PR
Browse files Browse the repository at this point in the history
fix rust-windowing#219 (minimum stroke thickness)
  • Loading branch information
pcwalton authored Oct 5, 2019
2 parents 8914cb4 + 3d0e911 commit 9965427
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion canvas/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,13 @@ impl CanvasRenderingContext2D {
let paint_id = self.scene.push_paint(&paint);

let mut stroke_style = self.current_state.resolve_stroke_style();
stroke_style.line_width = f32::max(stroke_style.line_width, HAIRLINE_STROKE_WIDTH);

// the smaller scale is relevant here, as we multiply by it and want to ensure it is always bigger than HAIRLINE_STROKE_WIDTH
let transform_scale = f32::min(self.current_state.transform.m11(), self.current_state.transform.m22());
// avoid the division in the normal case of sufficient thickness
if stroke_style.line_width * transform_scale < HAIRLINE_STROKE_WIDTH {
stroke_style.line_width = HAIRLINE_STROKE_WIDTH / transform_scale;
}

let mut outline = path.into_outline();
if !self.current_state.line_dash.is_empty() {
Expand Down

0 comments on commit 9965427

Please sign in to comment.