weirdboi_bevy_colour

Crates.ioweirdboi_bevy_colour
lib.rsweirdboi_bevy_colour
version0.1.0
created_at2025-08-08 04:54:38.566987+00
updated_at2025-08-08 04:54:38.566987+00
descriptionColour palettes for Bevy, with macros for compile-time palette definitions.
homepagehttps://weirdboi.dev/libraries/bevy-colours
repositoryhttps://weirdboi.dev/libraries/bevy-colours
max_upload_size
id1786206
size56,039
Louis Capitanchik (Commander-lol)

documentation

README

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.1.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.1 0.16
Commit count: 0

cargo fmt