Skip to content

Commit 8b9276a

Browse files
Limit bloom_3d float output to two decimal places. (#20897)
Objective Improve the readability of the float output in the bloom_3d example by formatting it to two decimal places. This makes the output cleaner and more consistent. Solution Used Rust’s formatting syntax (e.g., {:.2}) to ensure floats are displayed with exactly two decimal places. Applied this to all relevant print or debug output lines in the bloom_3d example.
1 parent 24c322e commit 8b9276a

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

examples/3d/bloom_3d.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,17 @@ fn update_bloom_settings(
106106
match bloom {
107107
(entity, Some(mut bloom)) => {
108108
text.0 = "Bloom (Toggle: Space)\n".to_string();
109-
text.push_str(&format!("(Q/A) Intensity: {}\n", bloom.intensity));
109+
text.push_str(&format!("(Q/A) Intensity: {:.2}\n", bloom.intensity));
110110
text.push_str(&format!(
111-
"(W/S) Low-frequency boost: {}\n",
111+
"(W/S) Low-frequency boost: {:.2}\n",
112112
bloom.low_frequency_boost
113113
));
114114
text.push_str(&format!(
115-
"(E/D) Low-frequency boost curvature: {}\n",
115+
"(E/D) Low-frequency boost curvature: {:.2}\n",
116116
bloom.low_frequency_boost_curvature
117117
));
118118
text.push_str(&format!(
119-
"(R/F) High-pass frequency: {}\n",
119+
"(R/F) High-pass frequency: {:.2}\n",
120120
bloom.high_pass_frequency
121121
));
122122
text.push_str(&format!(
@@ -126,12 +126,15 @@ fn update_bloom_settings(
126126
BloomCompositeMode::Additive => "Additive",
127127
}
128128
));
129-
text.push_str(&format!("(Y/H) Threshold: {}\n", bloom.prefilter.threshold));
130129
text.push_str(&format!(
131-
"(U/J) Threshold softness: {}\n",
130+
"(Y/H) Threshold: {:.2}\n",
131+
bloom.prefilter.threshold
132+
));
133+
text.push_str(&format!(
134+
"(U/J) Threshold softness: {:.2}\n",
132135
bloom.prefilter.threshold_softness
133136
));
134-
text.push_str(&format!("(I/K) Horizontal Scale: {}\n", bloom.scale.x));
137+
text.push_str(&format!("(I/K) Horizontal Scale: {:.2}\n", bloom.scale.x));
135138

136139
if keycode.just_pressed(KeyCode::Space) {
137140
commands.entity(entity).remove::<Bloom>();

0 commit comments

Comments
 (0)