codecraft 0.2.0

A minimalist 3D game engine built on parts of Bevy (ECS, color) with wgpu and winit: OpenPBR materials, clustered lighting, a yakui-drawn UI, audio and gamepad haptics; its binary maps any folder, and the symbols of its Rust files, as a 3D wall of boxes
Documentation
//! Colour, and the one place it changes space: authored in sRGB, rendered in
//! linear, converted here on the way to the GPU.
pub use bevy_color::{Alpha, Color, Mix};

use bevy_color::ColorToComponents;

/// A colour as the shaders want it: linear, premultiplied by nothing, RGBA.
pub fn linear_rgba(color: Color) -> [f32; 4] {
    color.to_linear().to_f32_array()
}

/// The same conversion for a clear value; `bevy_color`'s own `From` impls target an older `wgpu-types` major.
pub fn wgpu_color(color: Color) -> wgpu::Color {
    let c = color.to_linear();
    wgpu::Color {
        r: c.red as f64,
        g: c.green as f64,
        b: c.blue as f64,
        a: c.alpha as f64,
    }
}

/// A colour as yakui takes it: sRGB, eight bits a channel.
pub fn yakui_color(color: Color) -> yakui::geometry::Color {
    let c = color.to_srgba();
    let channel = |value: f32| (value.clamp(0.0, 1.0) * 255.0).round() as u8;
    yakui::geometry::Color::rgba(
        channel(c.red),
        channel(c.green),
        channel(c.blue),
        channel(c.alpha),
    )
}