mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 12:43:34 +00:00
Remove thiserror
from bevy_color
(#15777)
# Objective - Contributes to #15460 ## Solution - Removed `thiserror` from `bevy_color`
This commit is contained in:
parent
1be0ed33fc
commit
284e36af5e
3 changed files with 14 additions and 68 deletions
|
@ -16,7 +16,11 @@ bevy_reflect = { path = "../bevy_reflect", version = "0.15.0-dev", features = [
|
||||||
], optional = true }
|
], optional = true }
|
||||||
bytemuck = { version = "1", features = ["derive"] }
|
bytemuck = { version = "1", features = ["derive"] }
|
||||||
serde = { version = "1.0", features = ["derive"], optional = true }
|
serde = { version = "1.0", features = ["derive"], optional = true }
|
||||||
thiserror = "1.0"
|
derive_more = { version = "1", default-features = false, features = [
|
||||||
|
"error",
|
||||||
|
"from",
|
||||||
|
"display",
|
||||||
|
] }
|
||||||
wgpu-types = { version = "22", default-features = false, optional = true }
|
wgpu-types = { version = "22", default-features = false, optional = true }
|
||||||
encase = { version = "0.10", default-features = false }
|
encase = { version = "0.10", default-features = false }
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
#[cfg(feature = "bevy_reflect")]
|
#[cfg(feature = "bevy_reflect")]
|
||||||
use bevy_reflect::prelude::*;
|
use bevy_reflect::prelude::*;
|
||||||
|
use derive_more::derive::From;
|
||||||
|
|
||||||
/// 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.
|
||||||
///
|
///
|
||||||
|
@ -40,7 +41,7 @@ use bevy_reflect::prelude::*;
|
||||||
/// due to its perceptual uniformity and broad support for Bevy's color operations.
|
/// due to its perceptual uniformity and broad support for Bevy's color operations.
|
||||||
/// To avoid the cost of repeated conversion, and ensure consistent results where that is desired,
|
/// To avoid the cost of repeated conversion, and ensure consistent results where that is desired,
|
||||||
/// first convert this [`Color`] into your desired color space.
|
/// first convert this [`Color`] into your desired color space.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq, From)]
|
||||||
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(PartialEq, Default))]
|
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(PartialEq, Default))]
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
|
@ -426,66 +427,6 @@ impl Alpha for Color {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Srgba> for Color {
|
|
||||||
fn from(value: Srgba) -> Self {
|
|
||||||
Self::Srgba(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<LinearRgba> for Color {
|
|
||||||
fn from(value: LinearRgba) -> Self {
|
|
||||||
Self::LinearRgba(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Hsla> for Color {
|
|
||||||
fn from(value: Hsla) -> Self {
|
|
||||||
Self::Hsla(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Hsva> for Color {
|
|
||||||
fn from(value: Hsva) -> Self {
|
|
||||||
Self::Hsva(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Hwba> for Color {
|
|
||||||
fn from(value: Hwba) -> Self {
|
|
||||||
Self::Hwba(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Oklaba> for Color {
|
|
||||||
fn from(value: Oklaba) -> Self {
|
|
||||||
Self::Oklaba(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Oklcha> for Color {
|
|
||||||
fn from(value: Oklcha) -> Self {
|
|
||||||
Self::Oklcha(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Lcha> for Color {
|
|
||||||
fn from(value: Lcha) -> Self {
|
|
||||||
Self::Lcha(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Laba> for Color {
|
|
||||||
fn from(value: Laba) -> Self {
|
|
||||||
Self::Laba(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Xyza> for Color {
|
|
||||||
fn from(value: Xyza) -> Self {
|
|
||||||
Self::Xyza(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Color> for Srgba {
|
impl From<Color> for Srgba {
|
||||||
fn from(value: Color) -> Self {
|
fn from(value: Color) -> Self {
|
||||||
match value {
|
match value {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::{
|
||||||
use bevy_math::{ops, Vec3, Vec4};
|
use bevy_math::{ops, Vec3, Vec4};
|
||||||
#[cfg(feature = "bevy_reflect")]
|
#[cfg(feature = "bevy_reflect")]
|
||||||
use bevy_reflect::prelude::*;
|
use bevy_reflect::prelude::*;
|
||||||
use thiserror::Error;
|
use derive_more::derive::{Display, Error, From};
|
||||||
|
|
||||||
/// Non-linear standard RGB with alpha.
|
/// Non-linear standard RGB with alpha.
|
||||||
#[doc = include_str!("../docs/conversion.md")]
|
#[doc = include_str!("../docs/conversion.md")]
|
||||||
|
@ -421,16 +421,17 @@ impl From<Srgba> for Xyza {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Error returned if a hex string could not be parsed as a color.
|
/// Error returned if a hex string could not be parsed as a color.
|
||||||
#[derive(Debug, Error, PartialEq, Eq)]
|
#[derive(Debug, Error, Display, PartialEq, Eq, From)]
|
||||||
pub enum HexColorError {
|
pub enum HexColorError {
|
||||||
/// Parsing error.
|
/// Parsing error.
|
||||||
#[error("Invalid hex string")]
|
#[display("Invalid hex string")]
|
||||||
Parse(#[from] core::num::ParseIntError),
|
Parse(core::num::ParseIntError),
|
||||||
/// Invalid length.
|
/// Invalid length.
|
||||||
#[error("Unexpected length of hex string")]
|
#[display("Unexpected length of hex string")]
|
||||||
Length,
|
Length,
|
||||||
/// Invalid character.
|
/// Invalid character.
|
||||||
#[error("Invalid hex char")]
|
#[display("Invalid hex char")]
|
||||||
|
#[error(ignore)]
|
||||||
Char(char),
|
Char(char),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue