Skip to content

Commit 7b4ef53

Browse files
committed
Prepare for being able to switch rendering mode.
1 parent 6a01d9c commit 7b4ef53

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

src/ui/peakmeter.rs

+25-20
Original file line numberDiff line numberDiff line change
@@ -54,28 +54,33 @@ mod imp {
5454

5555
snapshot.push_rounded_clip(&rounded_rect);
5656

57-
let discrete_level = (level * NUM_BLOCKS as f32).floor() as u32;
58-
let mut block_width = width / NUM_BLOCKS;
59-
let extra_space = width - block_width * NUM_BLOCKS;
60-
if extra_space > 0 {
61-
block_width += 1;
62-
}
63-
let mut block_area_width = block_width;
64-
let mut block_area_x = 0;
65-
66-
for i in 0..discrete_level {
67-
if extra_space > 0 && i == extra_space {
68-
block_area_width -= 1;
57+
if false {
58+
snapshot.append_color(&RGBA::GREEN, &graphene::Rect::new(0.0, 0.0, level * w, h));
59+
} else {
60+
let discrete_level = (level * NUM_BLOCKS as f32).floor() as u32;
61+
let mut block_width = width / NUM_BLOCKS;
62+
let extra_space = width - block_width * NUM_BLOCKS;
63+
if extra_space > 0 {
64+
block_width += 1;
65+
}
66+
let mut block_area_width = block_width;
67+
let mut block_area_x = 0;
68+
69+
for i in 0..discrete_level {
70+
if extra_space > 0 && i == extra_space {
71+
block_area_width -= 1;
72+
}
73+
74+
let color = match i {
75+
0..GREEN_LIMIT => RGBA::GREEN,
76+
GREEN_LIMIT..YELLOW_LIMIT => RGBA::new(1.0, 1.0, 0.0, 1.0),
77+
_ => RGBA::RED,
78+
};
79+
snapshot.append_color(&color, &graphene::Rect::new(block_area_x as f32, 0.0, block_area_width as f32 - 1.0, h));
80+
block_area_x += block_area_width;
6981
}
70-
71-
let color = match i {
72-
0..GREEN_LIMIT => RGBA::GREEN,
73-
GREEN_LIMIT..YELLOW_LIMIT => RGBA::new(1.0, 1.0, 0.0, 1.0),
74-
_ => RGBA::RED,
75-
};
76-
snapshot.append_color(&color, &graphene::Rect::new(block_area_x as f32, 0.0, block_area_width as f32 - 1.0, h));
77-
block_area_x += block_area_width;
7882
}
83+
7984
snapshot.pop();
8085
}
8186

0 commit comments

Comments
 (0)