Ogeon / palette

A Rust library for linear color calculations and conversion
Apache License 2.0
748 stars 60 forks source link

Split out the `Scalar` from `Premultiply` to allow `PreAlpha<&T>` and more #319

Open Ogeon opened 1 year ago

Ogeon commented 1 year ago

Description

Create a separate trait (Premultiplied? Something more generic?) with only the Scalar type that both Premultiply and PreAlpha can depend on. This is breaking because it (re)moves an associated type and changes the requirements.

Motivation

Separating the operation of premultiplying from the requirements for being in PreAlpha allows us to construct PreAlpha<&T>, PreAlpha<&mut T>, PreAlpha<&mut [T]> and so on, without having to allow them to be alpha unmasked. This is useful for struct-of-arrays algorithms, among other things.