Browse Source

Dim chars colors.

master
Juergen Stuber 1 year ago
parent
commit
3ddb2b4f22
1 changed files with 8 additions and 4 deletions
  1. 8
    4
      src/bin/chars/main.rs

+ 8
- 4
src/bin/chars/main.rs View File

@@ -70,8 +70,10 @@ fn main() -> std::io::Result<()> {
70 70
         .collect::<Vec<_>>();
71 71
     for x in 0..(x_size / 8) {
72 72
         for y in 0..(y_size / 8) {
73
-            let fg = colors[rng.gen_range(0, colors.len())];
74
-            let bg = colors[rng.gen_range(0, colors.len())];
73
+            let fg = colors[rng.gen_range(0, colors.len())]
74
+                .interpolate(Color::black(), 0.8 * rng.gen::<f64>());
75
+            let bg = colors[rng.gen_range(0, colors.len())]
76
+                .interpolate(Color::black(), 0.8 * rng.gen::<f64>());
75 77
             let start_index = rng.gen_range(0, buffer.len() / 8) * 8;
76 78
             let bitmap = &buffer[start_index..(start_index + 8)];
77 79
             paint_char(&mut frame, x, y, bitmap, fg, bg);
@@ -81,8 +83,10 @@ fn main() -> std::io::Result<()> {
81 83
         if rng.gen::<f64>() < 0.02 {
82 84
             let x = rng.gen_range(0, x_size / 8);
83 85
             let y = rng.gen_range(0, y_size / 8);
84
-            let fg = colors[rng.gen_range(0, colors.len())];
85
-            let bg = colors[rng.gen_range(0, colors.len())];
86
+            let fg = colors[rng.gen_range(0, colors.len())]
87
+                .interpolate(Color::black(), 0.8 * rng.gen::<f64>());
88
+            let bg = colors[rng.gen_range(0, colors.len())]
89
+                .interpolate(Color::black(), 0.8 * rng.gen::<f64>());
86 90
             let start_index = rng.gen_range(0, buffer.len() / 8) * 8;
87 91
             let bitmap = &buffer[start_index..(start_index + 8)];
88 92
             paint_char(&mut frame, x, y, bitmap, fg, bg);

Loading…
Cancel
Save