Skip to content

Commit 44975d2

Browse files
committed
customize color scheme
1 parent c74387c commit 44975d2

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

gravity_simulation/src/main.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,19 @@ const MASS_ROW_OFFSET: f32 = 16.0;
4848
const MASS_FONT_SIZE: u16 = 18;
4949

5050
// Cycled through when the user adds bodies via the + button.
51-
const PALETTE: &[Color] = &[YELLOW, BLUE, RED, GREEN, PURPLE, ORANGE, PINK, SKYBLUE, LIME, GOLD];
51+
// const PALETTE: &[Color] = &[YELLOW, BLUE, RED, GREEN, PURPLE, ORANGE, PINK, SKYBLUE, LIME, GOLD];
52+
const PALETTE: &[Color] = &[
53+
Color::from_hex(0x00F0FF),
54+
Color::from_hex(0x2E5BFF),
55+
Color::from_hex(0xC0C8D8),
56+
Color::from_hex(0x0B0F1A),
57+
Color::from_hex(0x008B8B),
58+
Color::from_hex(0xB22222),
59+
Color::from_hex(0xFF4500),
60+
Color::from_hex(0xB57EDC),
61+
Color::from_hex(0x0A1A40),
62+
Color::from_hex(0xFF2D95),
63+
];
5264

5365
// A single gravitating body with position, velocity, mass, radius, and color.
5466
#[derive(Clone, Copy, Debug)]
@@ -361,7 +373,7 @@ fn initial_bodies(cx: f32, cy: f32) -> Vec<Body> {
361373
let angle = start_angle + i as f32 * angle_step;
362374
let pos = vec2(cx + spread * angle.cos(), cy - spread * angle.sin());
363375
let vel = vec2(-angle.sin(), -angle.cos()) * speed;
364-
Body::new(pos, vel, 10000.0, 30.0, [YELLOW, BLUE, RED][i])
376+
Body::new(pos, vel, 10000.0, 30.0, PALETTE[i % PALETTE.len()])
365377
}).collect()
366378
}
367379

0 commit comments

Comments
 (0)