Skip to content

Commit

Permalink
Don't overstride when drawing concentric circles
Browse files Browse the repository at this point in the history
When drawing concentric circles on protractor mode, check if radius is
larger than protractor radius *before* actually drawing it, not after.

This had the effect of circles being drawn outside the protractor and
partially cropped by the window area.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
  • Loading branch information
epilys committed Nov 24, 2024
1 parent 2a18e1f commit 2ff4251
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,11 @@ impl Rlr {
// Make concentric circles at distance `tick_size`
for i in 1..(length / 2.).floor() as i64 {
let r = (i as f64) * tick_size * 10.;
cr.arc(length / 2., length / 2., r, 0., 2. * std::f64::consts::PI);
cr.stroke().expect("Invalid cairo surface state");
if 2. * r >= length {
break;
}
cr.arc(length / 2., length / 2., r, 0., 2. * std::f64::consts::PI);
cr.stroke().expect("Invalid cairo surface state");
}
cr.restore().unwrap();

Expand Down

0 comments on commit 2ff4251

Please sign in to comment.