Skip to content

Commit 8319ccb

Browse files
Limit float output in some examples to two decimal places. (#20915)
# Objective - Improve the readability of float output in the depth_of_field, post_processing, and tonemapping examples by limiting it to two decimal places - This makes the output cleaner and more consistent. ## Solution - Use Rust’s formatting syntax (e.g., {:.2}) to ensure floats are displayed with exactly two decimal places. - Apply this to all relevant print and debug output lines in these examples.
1 parent 170f150 commit 8319ccb

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

examples/3d/depth_of_field.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,10 @@ impl AppSettings {
242242
let fov = PerspectiveProjection::default().fov;
243243

244244
format!(
245-
"Focal distance: {} m (Press Up/Down to change)
246-
Aperture F-stops: f/{} (Press Left/Right to change)
247-
Sensor height: {}mm
248-
Focal length: {}mm
245+
"Focal distance: {:.2} m (Press Up/Down to change)
246+
Aperture F-stops: f/{:.2} (Press Left/Right to change)
247+
Sensor height: {:.2}mm
248+
Focal length: {:.2}mm
249249
Mode: {} (Press Space to change)",
250250
self.focal_distance,
251251
self.aperture_f_stops,

examples/3d/post_processing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl Default for AppSettings {
142142
/// Creates help text at the bottom of the screen.
143143
fn create_help_text(app_settings: &AppSettings) -> Text {
144144
format!(
145-
"Chromatic aberration intensity: {} (Press Left or Right to change)",
145+
"Chromatic aberration intensity: {:.2} (Press Left or Right to change)",
146146
app_settings.chromatic_aberration_intensity
147147
)
148148
.into()

examples/3d/tonemapping.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -502,23 +502,23 @@ fn update_ui(
502502
if selected_parameter.value == 0 {
503503
text.push_str("> ");
504504
}
505-
text.push_str(&format!("Exposure: {}\n", color_grading.global.exposure));
505+
text.push_str(&format!("Exposure: {:.2}\n", color_grading.global.exposure));
506506
if selected_parameter.value == 1 {
507507
text.push_str("> ");
508508
}
509-
text.push_str(&format!("Gamma: {}\n", color_grading.shadows.gamma));
509+
text.push_str(&format!("Gamma: {:.2}\n", color_grading.shadows.gamma));
510510
if selected_parameter.value == 2 {
511511
text.push_str("> ");
512512
}
513513
text.push_str(&format!(
514-
"PreSaturation: {}\n",
514+
"PreSaturation: {:.2}\n",
515515
color_grading.shadows.saturation
516516
));
517517
if selected_parameter.value == 3 {
518518
text.push_str("> ");
519519
}
520520
text.push_str(&format!(
521-
"PostSaturation: {}\n",
521+
"PostSaturation: {:.2}\n",
522522
color_grading.global.post_saturation
523523
));
524524
text.push_str("(Space) Reset all to default\n");

0 commit comments

Comments
 (0)