Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This release has an [MSRV][] of 1.82.
### Added

* Add `BLACK`, `WHITE`, and `TRANSPARENT` constants to the color types. ([#64][] by [@waywardmonkeys][])
* The `serde` feature enables using `serde` with `AlphaColor`, `OpaqueColor`, `PremulColor`, and `Rgba8`. ([#61][] by [@waywardmonkeys][])

### Changed

Expand All @@ -31,6 +32,7 @@ This is the initial release.

[@waywardmonkeys]: https://github.com/waywardmonkeys

[#61]: https://github.com/linebender/color/pull/61
[#64]: https://github.com/linebender/color/pull/64
[#65]: https://github.com/linebender/color/pull/65

Expand Down
56 changes: 56 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion color/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ targets = []

[features]
default = ["std"]
std = []
std = ["serde?/std"]
libm = ["dep:libm"]
bytemuck = ["dep:bytemuck"]
serde = ["dep:serde"]

[dependencies]

Expand All @@ -32,5 +33,11 @@ default-features = false
version = "0.2.11"
optional = true

[dependencies.serde]
version = "1.0.215"
optional = true
default-features = false
features = ["derive"]

[lints]
workspace = true
2 changes: 2 additions & 0 deletions color/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ this trait for new color spaces.
- `libm`: Use floating point implementations from [libm][].
- `bytemuck`: Implement traits from `bytemuck` on [`AlphaColor`], [`OpaqueColor`],
[`PremulColor`], and [`Rgba8`].
- `serde`: Implement `serde::Deserialize` and `serde::Serialize` on [`AlphaColor`],
[`OpaqueColor`], [`PremulColor`], and [`Rgba8`].

At least one of `std` and `libm` is required; `std` overrides `libm`.

Expand Down
3 changes: 3 additions & 0 deletions color/src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::floatfuncs::FloatFuncs;
/// for spline interpolation. For cylindrical color spaces, hue fixup should
/// be applied before interpolation.
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[repr(transparent)]
pub struct OpaqueColor<CS> {
/// The components, which may be manipulated directly.
Expand All @@ -38,6 +39,7 @@ pub struct OpaqueColor<CS> {
///
/// See [`OpaqueColor`] for a discussion of arithmetic traits and interpolation.
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[repr(transparent)]
pub struct AlphaColor<CS> {
/// The components, which may be manipulated directly.
Expand All @@ -60,6 +62,7 @@ pub struct AlphaColor<CS> {
///
/// See [`OpaqueColor`] for a discussion of arithmetic traits and interpolation.
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[repr(transparent)]
pub struct PremulColor<CS> {
/// The components, which may be manipulated directly.
Expand Down
2 changes: 2 additions & 0 deletions color/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
//! - `libm`: Use floating point implementations from [libm][].
//! - `bytemuck`: Implement traits from `bytemuck` on [`AlphaColor`], [`OpaqueColor`],
//! [`PremulColor`], and [`Rgba8`].
//! - `serde`: Implement `serde::Deserialize` and `serde::Serialize` on [`AlphaColor`],
//! [`OpaqueColor`], [`PremulColor`], and [`Rgba8`].
//!
//! At least one of `std` and `libm` is required; `std` overrides `libm`.
//!
Expand Down
1 change: 1 addition & 0 deletions color/src/rgba8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::{AlphaColor, Srgb};
/// it is efficient and convenient, even if limited in accuracy and
/// gamut.
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[repr(C)]
pub struct Rgba8 {
/// Red component.
Expand Down