core: documentation changes.

This commit is contained in:
iwannabethedev 2023-05-15 00:36:46 +02:00 committed by Adrian Wielgosik
parent c86aed35a2
commit d0f8061c85
1 changed files with 8 additions and 13 deletions

View File

@ -33,18 +33,13 @@ impl LehmerRng {
} }
} }
/// An ARGB color value. /// This can represent both a premultiplied and an unmultiplied ARGB color value.
/// ///
/// It can be in two forms: /// Note that most operations only make sense on one of these representations:
/// - Pre-multiplied alpha, where the non-alpha values are pre-multiplied with /// For example, blending on premultiplied values, and applying a `ColorTransform` on
/// the alpha value. /// unmultiplied values. Make sure to convert the color to the correct form beforehand.
/// - Non-pre-multiplied alpha, where the non-alpha values are not pre-multiplied // TODO: Maybe split the type into `PremultipliedColor(i32)` and
/// with the alpha value. // `UnmultipliedColor(i32)`?
/// The type system as of this writing (May 2023) does not differentiate between
/// the two forms.
/// Notably, BitmapData stores internally its color values in pre-multiplied alpha form,
/// while the ActionScript interface uses non-pre-multiplied alpha form for color
/// values.
#[derive(Debug, Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Collect)] #[derive(Debug, Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Collect)]
#[collect(no_drop)] #[collect(no_drop)]
pub struct Color(i32); pub struct Color(i32);
@ -140,8 +135,8 @@ impl Color {
/// # Arguments /// # Arguments
/// ///
/// * `self` - Must be in pre-multiplied alpha form. /// * `self` - Must be in premultiplied form.
/// * `source` - Must be in pre-multiplied alpha form. /// * `source` - Must be in premultiplied form.
#[must_use] #[must_use]
pub fn blend_over(&self, source: &Self) -> Self { pub fn blend_over(&self, source: &Self) -> Self {
let sa = source.alpha(); let sa = source.alpha();