mirror of
https://github.com/bevyengine/bevy
synced 2025-02-16 14:08:32 +00:00
Reflect default in colorspaces in bevy_color
(#12528)
# Objective - For some reason, we don't reflect the Default trait in colorspaces ## Solution - Reflect it. ---
This commit is contained in:
parent
e9dc270d68
commit
7002b24379
11 changed files with 22 additions and 22 deletions
|
@ -1,7 +1,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
Alpha, Hsla, Hsva, Hwba, Laba, Lcha, LinearRgba, Oklaba, Oklcha, Srgba, StandardColor, Xyza,
|
Alpha, Hsla, Hsva, Hwba, Laba, Lcha, LinearRgba, Oklaba, Oklcha, Srgba, StandardColor, Xyza,
|
||||||
};
|
};
|
||||||
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
use bevy_reflect::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// An enumerated type that can represent any of the color types in this crate.
|
/// An enumerated type that can represent any of the color types in this crate.
|
||||||
|
@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize};
|
||||||
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
||||||
/// </div>
|
/// </div>
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
||||||
#[reflect(PartialEq, Serialize, Deserialize)]
|
#[reflect(PartialEq, Serialize, Deserialize, Default)]
|
||||||
pub enum Color {
|
pub enum Color {
|
||||||
/// A color in the sRGB color space with alpha.
|
/// A color in the sRGB color space with alpha.
|
||||||
Srgba(Srgba),
|
Srgba(Srgba),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{Alpha, Hsva, Hwba, Lcha, LinearRgba, Luminance, Mix, Srgba, StandardColor, Xyza};
|
use crate::{Alpha, Hsva, Hwba, Lcha, LinearRgba, Luminance, Mix, Srgba, StandardColor, Xyza};
|
||||||
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
use bevy_reflect::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Color in Hue-Saturation-Lightness (HSL) color space with alpha.
|
/// Color in Hue-Saturation-Lightness (HSL) color space with alpha.
|
||||||
|
@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
|
||||||
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
||||||
/// </div>
|
/// </div>
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
||||||
#[reflect(PartialEq, Serialize, Deserialize)]
|
#[reflect(PartialEq, Serialize, Deserialize, Default)]
|
||||||
pub struct Hsla {
|
pub struct Hsla {
|
||||||
/// The hue channel. [0.0, 360.0]
|
/// The hue channel. [0.0, 360.0]
|
||||||
pub hue: f32,
|
pub hue: f32,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{Alpha, Hwba, Lcha, LinearRgba, Srgba, StandardColor, Xyza};
|
use crate::{Alpha, Hwba, Lcha, LinearRgba, Srgba, StandardColor, Xyza};
|
||||||
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
use bevy_reflect::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Color in Hue-Saturation-Value (HSV) color space with alpha.
|
/// Color in Hue-Saturation-Value (HSV) color space with alpha.
|
||||||
|
@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
|
||||||
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
||||||
/// </div>
|
/// </div>
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
||||||
#[reflect(PartialEq, Serialize, Deserialize)]
|
#[reflect(PartialEq, Serialize, Deserialize, Default)]
|
||||||
pub struct Hsva {
|
pub struct Hsva {
|
||||||
/// The hue channel. [0.0, 360.0]
|
/// The hue channel. [0.0, 360.0]
|
||||||
pub hue: f32,
|
pub hue: f32,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
//!
|
//!
|
||||||
//! [_HWB - A More Intuitive Hue-Based Color Model_]: https://web.archive.org/web/20240226005220/http://alvyray.com/Papers/CG/HWB_JGTv208.pdf
|
//! [_HWB - A More Intuitive Hue-Based Color Model_]: https://web.archive.org/web/20240226005220/http://alvyray.com/Papers/CG/HWB_JGTv208.pdf
|
||||||
use crate::{Alpha, Lcha, LinearRgba, Srgba, StandardColor, Xyza};
|
use crate::{Alpha, Lcha, LinearRgba, Srgba, StandardColor, Xyza};
|
||||||
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
use bevy_reflect::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Color in Hue-Whiteness-Blackness (HWB) color space with alpha.
|
/// Color in Hue-Whiteness-Blackness (HWB) color space with alpha.
|
||||||
|
@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize};
|
||||||
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
||||||
/// </div>
|
/// </div>
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
||||||
#[reflect(PartialEq, Serialize, Deserialize)]
|
#[reflect(PartialEq, Serialize, Deserialize, Default)]
|
||||||
pub struct Hwba {
|
pub struct Hwba {
|
||||||
/// The hue channel. [0.0, 360.0]
|
/// The hue channel. [0.0, 360.0]
|
||||||
pub hue: f32,
|
pub hue: f32,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
Alpha, Hsla, Hsva, Hwba, LinearRgba, Luminance, Mix, Oklaba, Srgba, StandardColor, Xyza,
|
Alpha, Hsla, Hsva, Hwba, LinearRgba, Luminance, Mix, Oklaba, Srgba, StandardColor, Xyza,
|
||||||
};
|
};
|
||||||
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
use bevy_reflect::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Color in LAB color space, with alpha
|
/// Color in LAB color space, with alpha
|
||||||
|
@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};
|
||||||
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
||||||
/// </div>
|
/// </div>
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
||||||
#[reflect(PartialEq, Serialize, Deserialize)]
|
#[reflect(PartialEq, Serialize, Deserialize, Default)]
|
||||||
pub struct Laba {
|
pub struct Laba {
|
||||||
/// The lightness channel. [0.0, 1.5]
|
/// The lightness channel. [0.0, 1.5]
|
||||||
pub lightness: f32,
|
pub lightness: f32,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{Alpha, Laba, LinearRgba, Luminance, Mix, Srgba, StandardColor, Xyza};
|
use crate::{Alpha, Laba, LinearRgba, Luminance, Mix, Srgba, StandardColor, Xyza};
|
||||||
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
use bevy_reflect::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Color in LCH color space, with alpha
|
/// Color in LCH color space, with alpha
|
||||||
|
@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
|
||||||
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
||||||
/// </div>
|
/// </div>
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
||||||
#[reflect(PartialEq, Serialize, Deserialize)]
|
#[reflect(PartialEq, Serialize, Deserialize, Default)]
|
||||||
pub struct Lcha {
|
pub struct Lcha {
|
||||||
/// The lightness channel. [0.0, 1.5]
|
/// The lightness channel. [0.0, 1.5]
|
||||||
pub lightness: f32,
|
pub lightness: f32,
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::ops::{Div, Mul};
|
||||||
|
|
||||||
use crate::{color_difference::EuclideanDistance, Alpha, Luminance, Mix, StandardColor};
|
use crate::{color_difference::EuclideanDistance, Alpha, Luminance, Mix, StandardColor};
|
||||||
use bevy_math::Vec4;
|
use bevy_math::Vec4;
|
||||||
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
use bevy_reflect::prelude::*;
|
||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};
|
||||||
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
||||||
/// </div>
|
/// </div>
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
||||||
#[reflect(PartialEq, Serialize, Deserialize)]
|
#[reflect(PartialEq, Serialize, Deserialize, Default)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct LinearRgba {
|
pub struct LinearRgba {
|
||||||
/// The red channel. [0.0, 1.0]
|
/// The red channel. [0.0, 1.0]
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::{
|
||||||
color_difference::EuclideanDistance, Alpha, Hsla, Hsva, Hwba, Lcha, LinearRgba, Luminance, Mix,
|
color_difference::EuclideanDistance, Alpha, Hsla, Hsva, Hwba, Lcha, LinearRgba, Luminance, Mix,
|
||||||
Srgba, StandardColor, Xyza,
|
Srgba, StandardColor, Xyza,
|
||||||
};
|
};
|
||||||
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
use bevy_reflect::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Color in Oklab color space, with alpha
|
/// Color in Oklab color space, with alpha
|
||||||
|
@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
|
||||||
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
||||||
/// </div>
|
/// </div>
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
||||||
#[reflect(PartialEq, Serialize, Deserialize)]
|
#[reflect(PartialEq, Serialize, Deserialize, Default)]
|
||||||
pub struct Oklaba {
|
pub struct Oklaba {
|
||||||
/// The 'l' channel. [0.0, 1.0]
|
/// The 'l' channel. [0.0, 1.0]
|
||||||
pub l: f32,
|
pub l: f32,
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::{
|
||||||
color_difference::EuclideanDistance, Alpha, Hsla, Hsva, Hwba, Laba, Lcha, LinearRgba,
|
color_difference::EuclideanDistance, Alpha, Hsla, Hsva, Hwba, Laba, Lcha, LinearRgba,
|
||||||
Luminance, Mix, Oklaba, Srgba, StandardColor, Xyza,
|
Luminance, Mix, Oklaba, Srgba, StandardColor, Xyza,
|
||||||
};
|
};
|
||||||
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
use bevy_reflect::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Color in Oklch color space, with alpha
|
/// Color in Oklch color space, with alpha
|
||||||
|
@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
|
||||||
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
||||||
/// </div>
|
/// </div>
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
||||||
#[reflect(PartialEq, Serialize, Deserialize)]
|
#[reflect(PartialEq, Serialize, Deserialize, Default)]
|
||||||
pub struct Oklcha {
|
pub struct Oklcha {
|
||||||
/// The 'lightness' channel. [0.0, 1.0]
|
/// The 'lightness' channel. [0.0, 1.0]
|
||||||
pub lightness: f32,
|
pub lightness: f32,
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::ops::{Div, Mul};
|
||||||
use crate::color_difference::EuclideanDistance;
|
use crate::color_difference::EuclideanDistance;
|
||||||
use crate::{Alpha, LinearRgba, Luminance, Mix, StandardColor, Xyza};
|
use crate::{Alpha, LinearRgba, Luminance, Mix, StandardColor, Xyza};
|
||||||
use bevy_math::Vec4;
|
use bevy_math::Vec4;
|
||||||
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
use bevy_reflect::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ use thiserror::Error;
|
||||||
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
||||||
/// </div>
|
/// </div>
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
||||||
#[reflect(PartialEq, Serialize, Deserialize)]
|
#[reflect(PartialEq, Serialize, Deserialize, Default)]
|
||||||
pub struct Srgba {
|
pub struct Srgba {
|
||||||
/// The red channel. [0.0, 1.0]
|
/// The red channel. [0.0, 1.0]
|
||||||
pub red: f32,
|
pub red: f32,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{Alpha, LinearRgba, Luminance, Mix, StandardColor};
|
use crate::{Alpha, LinearRgba, Luminance, Mix, StandardColor};
|
||||||
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
use bevy_reflect::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// [CIE 1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space, also known as XYZ, with an alpha channel.
|
/// [CIE 1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space, also known as XYZ, with an alpha channel.
|
||||||
|
@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
|
||||||
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
#[doc = include_str!("../docs/diagrams/model_graph.svg")]
|
||||||
/// </div>
|
/// </div>
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
|
||||||
#[reflect(PartialEq, Serialize, Deserialize)]
|
#[reflect(PartialEq, Serialize, Deserialize, Default)]
|
||||||
pub struct Xyza {
|
pub struct Xyza {
|
||||||
/// The x-axis. [0.0, 1.0]
|
/// The x-axis. [0.0, 1.0]
|
||||||
pub x: f32,
|
pub x: f32,
|
||||||
|
|
Loading…
Add table
Reference in a new issue