- for (int level = -18; level < 9; ++level) {
- double min_y = lufs_to_pos(level + 1.0, height) + 1.0;
- double max_y = lufs_to_pos(level, height) - 1.0;
+ for (int level = floor(min_level); level <= ceil(max_level); ++level) {
+ double min_y = lufs_to_pos(level + 1.0, height, min_level, max_level) + segment_margin * 0.5;
+ double max_y = lufs_to_pos(level, height, min_level, max_level) - segment_margin * 0.5;