Skip to content

Commit b7b45e0

Browse files
committed
Rename Transparency to WithAlpha
1 parent 9084414 commit b7b45e0

File tree

16 files changed

+40
-40
lines changed

16 files changed

+40
-40
lines changed

palette/src/alpha/alpha.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::encoding::pixel::RawPixel;
1515
use crate::float::Float;
1616
use crate::{
1717
clamp, Blend, Component, ComponentWise, GetHue, Hue, Limited, Mix, Pixel, Saturate, Shade,
18-
Transparency,
18+
WithAlpha,
1919
};
2020

2121
/// An alpha component wrapper for colors.
@@ -44,7 +44,7 @@ impl<C, T: Component> Alpha<C, T> {
4444
}
4545
}
4646

47-
impl<C1: Transparency<T>, C2, T: Component> FromColorUnclamped<C1> for Alpha<C2, T>
47+
impl<C1: WithAlpha<T>, C2, T: Component> FromColorUnclamped<C1> for Alpha<C2, T>
4848
where
4949
C1::Color: IntoColorUnclamped<C2>,
5050
{
@@ -58,7 +58,7 @@ where
5858
}
5959
}
6060

61-
impl<C, A: Component> Transparency<A> for Alpha<C, A> {
61+
impl<C, A: Component> WithAlpha<A> for Alpha<C, A> {
6262
type Color = C;
6363
type WithAlpha = Self;
6464

palette/src/alpha/mod.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
use crate::Component;
22

33
#[doc(hidden)]
4-
pub use palette_derive::Transparency;
4+
pub use palette_derive::WithAlpha;
55

66
pub use self::alpha::*;
77

88
mod alpha;
99

1010
/// A trait for color types that can have or be given transparency (alpha channel).
1111
///
12-
/// `Transparency` is an interface for adding, removing and setting the alpha
12+
/// `WithAlpha` is an interface for adding, removing and setting the alpha
1313
/// channel of a color type. The color type itself doesn't need to store the
1414
/// transparency value as it can be transformed into or wrapped in a type that
1515
/// has a representation of transparency. This would typically be done by
@@ -23,9 +23,9 @@ mod alpha;
2323
/// Derived without an internal alpha channel:
2424
///
2525
/// ```
26-
/// use palette::Transparency;
26+
/// use palette::WithAlpha;
2727
///
28-
/// #[derive(Transparency)]
28+
/// #[derive(WithAlpha)]
2929
/// struct CustomColor {
3030
/// redness: f32,
3131
/// glow: f32,
@@ -45,9 +45,9 @@ mod alpha;
4545
/// Derived with an internal alpha channel:
4646
///
4747
/// ```
48-
/// use palette::Transparency;
48+
/// use palette::WithAlpha;
4949
///
50-
/// #[derive(Transparency)]
50+
/// #[derive(WithAlpha)]
5151
/// struct CustomColor {
5252
/// redness: f32,
5353
/// glow: f32,
@@ -67,7 +67,7 @@ mod alpha;
6767
///
6868
/// assert_eq!(transparent.alpha, 10);
6969
/// ```
70-
pub trait Transparency<A: Component>: Sized {
70+
pub trait WithAlpha<A: Component>: Sized {
7171
/// The opaque color type, without any transparency.
7272
///
7373
/// This is typically `Self`.
@@ -76,14 +76,14 @@ pub trait Transparency<A: Component>: Sized {
7676
/// The color type with transparency applied.
7777
///
7878
/// This is typically `Alpha<Self::Color, A>`.
79-
type WithAlpha: Transparency<A, Color = Self::Color, WithAlpha = Self::WithAlpha>;
79+
type WithAlpha: WithAlpha<A, Color = Self::Color, WithAlpha = Self::WithAlpha>;
8080

8181
/// Transforms the color into a transparent color with the provided
8282
/// alpha value. If `Self` already has a transparency, it is
8383
/// overwritten.
8484
///
8585
/// ```
86-
/// use palette::{Srgb, Transparency};
86+
/// use palette::{Srgb, WithAlpha};
8787
///
8888
/// let color = Srgb::new(255u8, 0, 255);
8989
///
@@ -102,7 +102,7 @@ pub trait Transparency<A: Component>: Sized {
102102
/// `A::max_intensity()` to make it opaque.
103103
///
104104
/// ```
105-
/// use palette::{Srgba, Srgb, Transparency};
105+
/// use palette::{Srgba, Srgb, WithAlpha};
106106
///
107107
/// let transparent = Srgba::new(255u8, 0, 255, 10);
108108
///
@@ -120,7 +120,7 @@ pub trait Transparency<A: Component>: Sized {
120120
/// `A::max_intensity()` to make it opaque.
121121
///
122122
/// ```
123-
/// use palette::{Srgba, Srgb, Transparency};
123+
/// use palette::{Srgba, Srgb, WithAlpha};
124124
///
125125
/// let transparent = Srgba::new(255u8, 0, 255, 10);
126126
///
@@ -135,7 +135,7 @@ pub trait Transparency<A: Component>: Sized {
135135
/// field. If `Self` already has a transparency, it is overwritten.
136136
///
137137
/// ```
138-
/// use palette::{Srgb, Srgba, Transparency};
138+
/// use palette::{Srgb, Srgba, WithAlpha};
139139
///
140140
/// let color = Srgb::new(255u8, 0, 255);
141141
///
@@ -150,7 +150,7 @@ pub trait Transparency<A: Component>: Sized {
150150
/// already has a transparency, it is overwritten.
151151
///
152152
/// ```
153-
/// use palette::{Srgb, Srgba, Transparency};
153+
/// use palette::{Srgb, Srgba, WithAlpha};
154154
///
155155
/// let color = Srgb::new(255u8, 0, 255);
156156
///

palette/src/convert.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! The default minimum requirement is to implement `FromColorUnclamped<Xyz>`, but it can
77
//! also be customized to make use of generics and have other manual implementations.
88
//!
9-
//! It is also recommended to derive or implement [`Transparency`](../trait.Transparency.html),
9+
//! It is also recommended to derive or implement [`WithAlpha`](../trait.WithAlpha.html),
1010
//! to be able to convert between all `Alpha` wrapped color types.
1111
//!
1212
//! ## Configuration Attributes
@@ -200,7 +200,7 @@
200200
//! #[macro_use]
201201
//! extern crate approx;
202202
//!
203-
//! use palette::{LinSrgba, Srgb, IntoColor, Transparency};
203+
//! use palette::{LinSrgba, Srgb, IntoColor, WithAlpha};
204204
//! use palette::rgb::{Rgb, RgbSpace, RgbStandard};
205205
//! use palette::encoding::Linear;
206206
//! use palette::white_point::D65;
@@ -211,7 +211,7 @@
211211
//! skip_derives(Rgb),
212212
//! rgb_space = "palette::encoding::Srgb"
213213
//! )]
214-
//! #[derive(PartialEq, Debug, FromColorUnclamped, Transparency)]
214+
//! #[derive(PartialEq, Debug, FromColorUnclamped, WithAlpha)]
215215
//! struct CssRgb {
216216
//! red: u8,
217217
//! green: u8,
@@ -532,7 +532,7 @@ mod tests {
532532
palette_internal,
533533
palette_internal_not_base_type
534534
)]
535-
#[derive(FromColorUnclamped, Transparency)]
535+
#[derive(FromColorUnclamped, WithAlpha)]
536536
struct WithXyz<S: RgbSpace>(PhantomData<S>);
537537

538538
impl<S: RgbSpace> Clone for WithXyz<S> {
@@ -601,7 +601,7 @@ mod tests {
601601
palette_internal,
602602
palette_internal_not_base_type
603603
)]
604-
#[derive(Copy, Clone, FromColorUnclamped, Transparency)]
604+
#[derive(Copy, Clone, FromColorUnclamped, WithAlpha)]
605605
struct WithoutXyz<T: FloatComponent>(PhantomData<T>);
606606

607607
impl<T: FloatComponent> Limited for WithoutXyz<T> {

palette/src/hsl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub type Hsla<S = Srgb, T = f32> = Alpha<Hsl<S, T>, T>;
3535
///
3636
/// See [HSV](struct.Hsv.html) for a very similar color space, with brightness
3737
/// instead of lightness.
38-
#[derive(Debug, PartialEq, Pixel, FromColorUnclamped, Transparency)]
38+
#[derive(Debug, PartialEq, Pixel, FromColorUnclamped, WithAlpha)]
3939
#[cfg_attr(feature = "serializing", derive(Serialize, Deserialize))]
4040
#[palette(
4141
palette_internal,

palette/src/hsv.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub type Hsva<S = Srgb, T = f32> = Alpha<Hsv<S, T>, T>;
3232
/// _lightness_. The difference is that, for example, red (100% R, 0% G, 0% B)
3333
/// and white (100% R, 100% G, 100% B) has the same brightness (or value), but
3434
/// not the same lightness.
35-
#[derive(Debug, PartialEq, Pixel, FromColorUnclamped, Transparency)]
35+
#[derive(Debug, PartialEq, Pixel, FromColorUnclamped, WithAlpha)]
3636
#[cfg_attr(feature = "serializing", derive(Serialize, Deserialize))]
3737
#[palette(
3838
palette_internal,

palette/src/hwb.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub type Hwba<S = Srgb, T = f32> = Alpha<Hwb<S, T>, T>;
3333
///
3434
/// It is very intuitive for humans to use and many color-pickers are based on
3535
/// the HWB color system
36-
#[derive(Debug, PartialEq, Pixel, FromColorUnclamped, Transparency)]
36+
#[derive(Debug, PartialEq, Pixel, FromColorUnclamped, WithAlpha)]
3737
#[cfg_attr(feature = "serializing", derive(Serialize, Deserialize))]
3838
#[palette(
3939
palette_internal,

palette/src/lab.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub type Laba<Wp, T = f32> = Alpha<Lab<Wp, T>, T>;
3333
///
3434
/// The parameters of L\*a\*b\* are quite different, compared to many other
3535
/// color spaces, so manipulating them manually may be unintuitive.
36-
#[derive(Debug, PartialEq, Pixel, FromColorUnclamped, Transparency)]
36+
#[derive(Debug, PartialEq, Pixel, FromColorUnclamped, WithAlpha)]
3737
#[cfg_attr(feature = "serializing", derive(Serialize, Deserialize))]
3838
#[palette(
3939
palette_internal,

palette/src/lch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub type Lcha<Wp, T = f32> = Alpha<Lch<Wp, T>, T>;
2828
/// it's a cylindrical color space, like [HSL](struct.Hsl.html) and
2929
/// [HSV](struct.Hsv.html). This gives it the same ability to directly change
3030
/// the hue and colorfulness of a color, while preserving other visual aspects.
31-
#[derive(Debug, PartialEq, Pixel, FromColorUnclamped, Transparency)]
31+
#[derive(Debug, PartialEq, Pixel, FromColorUnclamped, WithAlpha)]
3232
#[cfg_attr(feature = "serializing", derive(Serialize, Deserialize))]
3333
#[palette(
3434
palette_internal,

palette/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ use float::Float;
185185

186186
use luma::Luma;
187187

188-
pub use alpha::{Alpha, Transparency};
188+
pub use alpha::{Alpha, WithAlpha};
189189
pub use blend::Blend;
190190
#[cfg(feature = "std")]
191191
pub use gradient::Gradient;

palette/src/luma/luma.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub type Lumaa<S = Srgb, T = f32> = Alpha<Luma<S, T>, T>;
3333
/// perceived to be. It's basically the `Y` component of [CIE
3434
/// XYZ](struct.Xyz.html). The lack of any form of hue representation limits
3535
/// the set of operations that can be performed on it.
36-
#[derive(Debug, PartialEq, Pixel, FromColorUnclamped, Transparency)]
36+
#[derive(Debug, PartialEq, Pixel, FromColorUnclamped, WithAlpha)]
3737
#[cfg_attr(feature = "serializing", derive(Serialize, Deserialize))]
3838
#[palette(
3939
palette_internal,

palette/src/rgb/rgb.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub type Rgba<S = Srgb, T = f32> = Alpha<Rgb<S, T>, T>;
4343
/// linear, meaning that gamma correction is required when converting to and
4444
/// from a displayable RGB, such as sRGB. See the [`pixel`](pixel/index.html)
4545
/// module for encoding formats.
46-
#[derive(Debug, PartialEq, Pixel, FromColorUnclamped, Transparency)]
46+
#[derive(Debug, PartialEq, Pixel, FromColorUnclamped, WithAlpha)]
4747
#[cfg_attr(feature = "serializing", derive(Serialize, Deserialize))]
4848
#[palette(
4949
palette_internal,

palette/src/xyz.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub type Xyza<Wp = D65, T = f32> = Alpha<Xyz<Wp, T>, T>;
3232
///
3333
/// Conversions and operations on this color space depend on the defined white
3434
/// point
35-
#[derive(Debug, PartialEq, Pixel, FromColorUnclamped, Transparency)]
35+
#[derive(Debug, PartialEq, Pixel, FromColorUnclamped, WithAlpha)]
3636
#[cfg_attr(feature = "serializing", derive(Serialize, Deserialize))]
3737
#[palette(
3838
palette_internal,

palette/src/yxy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub type Yxya<Wp = D65, T = f32> = Alpha<Yxy<Wp, T>, T>;
2828
/// for the color spaces are a plot of this color space's x and y coordiantes.
2929
///
3030
/// Conversions and operations on this color space depend on the white point.
31-
#[derive(Debug, PartialEq, Pixel, FromColorUnclamped, Transparency)]
31+
#[derive(Debug, PartialEq, Pixel, FromColorUnclamped, WithAlpha)]
3232
#[cfg_attr(feature = "serializing", derive(Serialize, Deserialize))]
3333
#[palette(
3434
palette_internal,

palette_derive/src/alpha/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
pub use self::transparency::derive as derive_transparency;
1+
pub use self::with_alpha::derive as derive_with_alpha;
22

3-
mod transparency;
3+
mod with_alpha;

palette_derive/src/alpha/transparency.rs palette_derive/src/alpha/with_alpha.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ fn implement_for_internal_alpha(
4949
alpha_type: &Type,
5050
item_meta: &TypeItemAttributes,
5151
) -> TokenStream2 {
52-
let transparency_trait_path = util::path(["Transparency"], item_meta.internal);
52+
let with_alpha_trait_path = util::path(["WithAlpha"], item_meta.internal);
5353
let component_trait_path = util::path(["Component"], item_meta.internal);
5454

5555
let (impl_generics, type_generics, where_clause) = generics.split_for_impl();
5656

5757
quote! {
5858
#[automatically_derived]
59-
impl #impl_generics #transparency_trait_path<#alpha_type> for #ident #type_generics #where_clause {
59+
impl #impl_generics #with_alpha_trait_path<#alpha_type> for #ident #type_generics #where_clause {
6060
type Color = Self;
6161
type WithAlpha = Self;
6262

@@ -84,7 +84,7 @@ fn implement_for_external_alpha(
8484
generics: &Generics,
8585
item_meta: &TypeItemAttributes,
8686
) -> TokenStream2 {
87-
let transparency_trait_path = util::path(["Transparency"], item_meta.internal);
87+
let with_alpha_trait_path = util::path(["WithAlpha"], item_meta.internal);
8888
let component_trait_path = util::path(["Component"], item_meta.internal);
8989
let alpha_path = util::path(["Alpha"], item_meta.internal);
9090

@@ -101,7 +101,7 @@ fn implement_for_external_alpha(
101101

102102
quote! {
103103
#[automatically_derived]
104-
impl #impl_generics #transparency_trait_path<#alpha_type> for #ident #type_generics #where_clause {
104+
impl #impl_generics #with_alpha_trait_path<#alpha_type> for #ident #type_generics #where_clause {
105105
type Color = Self;
106106
type WithAlpha = #alpha_path<Self, #alpha_type>;
107107

palette_derive/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ const PREFERRED_CONVERSION_SOURCE: &[(&str, &str)] = &[
5252
("Yxy", "Xyz"),
5353
];
5454

55-
#[proc_macro_derive(Transparency, attributes(palette))]
56-
pub fn derive_transparency(tokens: TokenStream) -> TokenStream {
57-
syn_try!(alpha::derive_transparency(tokens))
55+
#[proc_macro_derive(WithAlpha, attributes(palette))]
56+
pub fn derive_with_alpha(tokens: TokenStream) -> TokenStream {
57+
syn_try!(alpha::derive_with_alpha(tokens))
5858
}
5959

6060
#[proc_macro_derive(FromColorUnclamped, attributes(palette))]

0 commit comments

Comments
 (0)