2 unstable releases
Uses new Rust 2024
| 0.2.0 | Oct 2, 2025 |
|---|---|
| 0.1.0 | Aug 8, 2025 |
#747 in Game dev
158 downloads per month
22KB
215 lines
Bevy Colour Palettes
A Rust library providing a collection of popular colour palettes for the Bevy game engine, with utilities for interacting with them.
-
Create colour palettes: Create flexible colour palettes with the
palette!macro -
Pre-defined Colour Palettes: Includes several popular colour palettes from Lospec:
-
Visual Documentation: Each palette includes custom HTML when generating a Rustdoc to showcase the available colours. Integrates nicely with IDE doc previews
Installation
Add this to your Cargo.toml:
[dependencies]
weirdboi_bevy_colour = "0.2.0"
Usage
Using Existing Palettes
use bevy::prelude::*;
use weirdboi_bevy_colour::Dawnbringer16;
fn setup(mut commands: Commands) {
let mut x = 0.0;
// Spawn a coloured square for each colour in the palette
for color in &Dawnbringer16 {
commands.spawn((
Sprite {
color,
custom_size: Some(Vec2::new(40.0, 40.0)),
..default()
},
Transform::from_xyz(x, 0.0, 0.0)
));
x += 50.0;
}
}
Creating Custom Palettes
You can create your own colour palettes using the palette! macro:
use weirdboi_bevy_colour::palette;
palette!(MyGamePalette {
"hero": (0.2, 0.6, 0.9),
"enemy": (0.9, 0.2, 0.3),
"background": (0.1, 0.1, 0.2),
"highlight": (1.0, 0.8, 0.0),
});
// Now you can use your palette just like the built-in ones:
let hero_colour = MyGamePalette::HERO;
let enemy_colour = MyGamePalette::enemy();
let bg_colour = MyGamePalette::get("BaCKgrouND").unwrap();
// Iterate over all colours
for colour in &MyGamePalette {
// Use colour...
}
Bevy Compatibility
| version | bevy |
|---|---|
| 0.2 | 0.17 |
| 0.1 | 0.16 |
Dependencies
~21–34MB
~556K SLoC