forked from processing/libprocessing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolor.rs
More file actions
35 lines (31 loc) · 687 Bytes
/
color.rs
File metadata and controls
35 lines (31 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use bevy::color::{LinearRgba, Srgba};
/// A sRGB (?) color
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}
impl From<Color> for bevy::color::Color {
fn from(color: Color) -> Self {
bevy::color::Color::srgba(color.r, color.g, color.b, color.a)
}
}
impl From<LinearRgba> for Color {
fn from(lin: LinearRgba) -> Self {
let srgb: Srgba = lin.into();
srgb.into()
}
}
impl From<Srgba> for Color {
fn from(srgb: Srgba) -> Self {
Color {
r: srgb.red,
g: srgb.green,
b: srgb.blue,
a: srgb.alpha,
}
}
}