Skip to content

Commit 1aa33a0

Browse files
author
OetkenPurveyorOfCode
committed
Cooler colors
1 parent 043b441 commit 1aa33a0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ struct Rect {
1313
y_max: f64,
1414
}
1515

16+
fn map_iter_to_color(iter: usize, iterations: usize) -> u32{
17+
((255*iter / iterations) as u32 * 255 * 255) & 0xFF_FF_00_00
18+
}
19+
1620
fn transform_pixel_to_coord_x(value: u32, width: usize, rect: &Rect) -> f64 {
1721
let x_coord = value as f64 / width as f64;
1822
let x_coord = (rect.x_max - rect.x_min) * x_coord + rect.x_min;
@@ -53,9 +57,9 @@ fn render(buffer: &mut Vec<u32>, width: usize, height: usize, rect: &Rect, itera
5357
iter += 1;
5458
}
5559
if iter == iterations {
56-
0x00_00_00_FF
60+
0xFF_00_00_00
5761
} else {
58-
0x00_FF_FF_FF
62+
map_iter_to_color(iter, iterations)
5963
}
6064
})
6165
.collect();

0 commit comments

Comments
 (0)