1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 22:30:03 -04:00

Use ..= range arguments to remap functions

This commit is contained in:
Emil Ernerfeldt
2020-04-25 11:11:44 +02:00
parent 663fbda90c
commit 4cc6ca7236
6 changed files with 38 additions and 45 deletions

View File

@@ -154,7 +154,7 @@ impl Path {
pub fn add_circle(&mut self, center: Pos2, radius: f32) {
let n = 32; // TODO: parameter
for i in 0..n {
let angle = remap(i as f32, 0.0, n as f32, 0.0, TAU);
let angle = remap(i as f32, 0.0..=n as f32, 0.0..=TAU);
let normal = vec2(angle.cos(), angle.sin());
self.add_point(center + radius * normal, normal);
}
@@ -222,10 +222,8 @@ impl Path {
for i in 0..=n {
let angle = remap(
i as f32,
0.0,
n as f32,
quadrant * RIGHT_ANGLE,
(quadrant + 1.0) * RIGHT_ANGLE,
0.0..=n as f32,
quadrant * RIGHT_ANGLE..=(quadrant + 1.0) * RIGHT_ANGLE,
);
let normal = vec2(angle.cos(), angle.sin());
self.add_point(center + radius * normal, normal);