Rename GradientStops to Gradient and the legacy Gradient/Fill structs to LegacyGradient/LegacyFill

This commit is contained in:
Keavon Chambers
2026-07-20 15:27:21 -07:00
committed by Dennis Kobert
parent 21eae1e2a1
commit fd7f67b3e9
45 changed files with 296 additions and 300 deletions

View File

@@ -13,7 +13,7 @@ impl Adjust<Color> for Color {
mod adjust_std {
use super::*;
use raster_types::{CPU, Raster};
use vector_types::GradientStops;
use vector_types::Gradient;
impl Adjust<Color> for Raster<CPU> {
fn adjust(&mut self, map_fn: impl Fn(&Color) -> Color) {
@@ -22,7 +22,7 @@ mod adjust_std {
}
}
}
impl Adjust<Color> for GradientStops {
impl Adjust<Color> for Gradient {
fn adjust(&mut self, map_fn: impl Fn(&Color) -> Color) {
for color in self.color.iter_mut() {
*color = map_fn(color);

View File

@@ -14,7 +14,7 @@ use num_traits::float::Float;
#[cfg(feature = "std")]
use raster_types::{CPU, Raster};
#[cfg(feature = "std")]
use vector_types::GradientStops;
use vector_types::Gradient;
// TODO: Implement the following:
// Color Balance
@@ -53,7 +53,7 @@ fn luminance<T: Adjust<Color> + Clone + Send + Sync + no_std_types::context::Cac
#[implementations(
Raster<CPU>,
Color,
GradientStops,
Gradient,
)]
#[gpu_image]
mut input: T,
@@ -78,7 +78,7 @@ fn gamma_correction<T: Adjust<Color> + Clone + Send + Sync + no_std_types::conte
#[implementations(
Raster<CPU>,
Color,
GradientStops,
Gradient,
)]
#[gpu_image]
mut input: T,
@@ -100,7 +100,7 @@ fn extract_channel<T: Adjust<Color> + Clone + Send + Sync + no_std_types::contex
#[implementations(
Raster<CPU>,
Color,
GradientStops,
Gradient,
)]
#[gpu_image]
mut input: T,
@@ -124,7 +124,7 @@ fn make_opaque<T: Adjust<Color> + Clone + Send + Sync + no_std_types::context::C
#[implementations(
Raster<CPU>,
Color,
GradientStops,
Gradient,
)]
#[gpu_image]
mut input: T,
@@ -146,7 +146,7 @@ fn brightness_contrast_classic<T: Adjust<Color> + Clone + Send + Sync + no_std_t
#[implementations(
Raster<CPU>,
Color,
GradientStops,
Gradient,
)]
#[gpu_image]
mut input: T,
@@ -177,7 +177,7 @@ fn brightness_contrast<T: Adjust<Color> + Clone + Send + Sync + no_std_types::co
#[implementations(
Raster<CPU>,
Color,
GradientStops,
Gradient,
)]
#[gpu_image]
mut input: T,
@@ -258,7 +258,7 @@ fn levels<T: Adjust<Color> + Clone + Send + Sync + no_std_types::context::CacheH
#[implementations(
Raster<CPU>,
Color,
GradientStops,
Gradient,
)]
#[gpu_image]
mut image: T,
@@ -337,7 +337,7 @@ fn black_and_white<T: Adjust<Color> + Clone + Send + Sync + no_std_types::contex
#[implementations(
Raster<CPU>,
Color,
GradientStops,
Gradient,
)]
#[gpu_image]
mut image: T,
@@ -420,7 +420,7 @@ fn hue_saturation<T: Adjust<Color> + Clone + Send + Sync + no_std_types::context
#[implementations(
Raster<CPU>,
Color,
GradientStops,
Gradient,
)]
#[gpu_image]
mut input: T,
@@ -452,7 +452,7 @@ fn invert<T: Adjust<Color> + Clone + Send + Sync + no_std_types::context::CacheH
#[implementations(
Raster<CPU>,
Color,
GradientStops,
Gradient,
)]
#[gpu_image]
mut input: T,
@@ -473,7 +473,7 @@ fn threshold<T: Adjust<Color> + Clone + Send + Sync + no_std_types::context::Cac
#[implementations(
Raster<CPU>,
Color,
GradientStops,
Gradient,
)]
#[gpu_image]
mut image: T,
@@ -519,7 +519,7 @@ fn vibrance<T: Adjust<Color> + Clone + Send + Sync + no_std_types::context::Cach
#[implementations(
Raster<CPU>,
Color,
GradientStops,
Gradient,
)]
#[gpu_image]
mut image: T,
@@ -721,7 +721,7 @@ fn channel_mixer<T: Adjust<Color> + Clone + Send + Sync + no_std_types::context:
#[implementations(
Raster<CPU>,
Color,
GradientStops,
Gradient,
)]
#[gpu_image]
mut image: T,
@@ -853,7 +853,7 @@ fn selective_color<T: Adjust<Color> + Clone + Send + Sync + no_std_types::contex
#[implementations(
Raster<CPU>,
Color,
GradientStops,
Gradient,
)]
#[gpu_image]
mut image: T,
@@ -999,7 +999,7 @@ fn posterize<T: Adjust<Color> + Clone + Send + Sync + no_std_types::context::Cac
#[implementations(
Raster<CPU>,
Color,
GradientStops,
Gradient,
)]
#[gpu_image]
mut input: T,
@@ -1028,7 +1028,7 @@ fn exposure<T: Adjust<Color> + Clone + Send + Sync + no_std_types::context::Cach
#[implementations(
Raster<CPU>,
Color,
GradientStops,
Gradient,
)]
#[gpu_image]
mut input: T,

View File

@@ -6,7 +6,7 @@ use no_std_types::registry::types::PercentageF32;
#[cfg(feature = "std")]
use raster_types::{CPU, Raster};
#[cfg(feature = "std")]
use vector_types::{GradientStop, GradientStops};
use vector_types::{Gradient, GradientStop};
pub trait Blend<P: Pixel> {
fn blend(&self, under: &Self, blend_fn: impl Fn(P, P) -> P) -> Self;
@@ -36,7 +36,7 @@ mod blend_std {
}
}
impl Blend<Color> for GradientStops {
impl Blend<Color> for Gradient {
fn blend(&self, under: &Self, blend_fn: impl Fn(Color, Color) -> Color) -> Self {
let mut combined_stops = self.position.iter().chain(under.position.iter()).copied().collect::<Vec<_>>();
combined_stops.dedup_by(|a, b| (*a - *b).abs() < 1e-6);
@@ -47,7 +47,7 @@ mod blend_std {
let color = blend_fn(over_color, under_color);
GradientStop { position, midpoint: 0.5, color }
});
GradientStops::new(stops)
Gradient::new(stops)
}
}
}
@@ -111,7 +111,7 @@ fn mix<T: Blend<Color> + Clone + Send + Sync + core_types::CacheHash + 'static>(
#[implementations(
Raster<CPU>,
Color,
GradientStops,
Gradient,
)]
#[gpu_image]
over: T,
@@ -119,7 +119,7 @@ fn mix<T: Blend<Color> + Clone + Send + Sync + core_types::CacheHash + 'static>(
#[implementations(
Raster<CPU>,
Color,
GradientStops,
Gradient,
)]
#[gpu_image]
under: T,
@@ -135,7 +135,7 @@ fn color_overlay<T: Adjust<Color> + Clone + Send + Sync + no_std_types::context:
#[implementations(
Raster<CPU>,
Color,
GradientStops,
Gradient,
)]
#[gpu_image]
mut image: T,

View File

@@ -1,9 +1,9 @@
//! Not immediately shader compatible due to needing [`GradientStops`] as a param, which needs [`Vec`]
//! Not immediately shader compatible due to needing [`Gradient`] as a param, which needs [`Vec`]
use crate::adjust::Adjust;
use core_types::{Color, Ctx};
use raster_types::{CPU, Raster};
use vector_types::GradientStops;
use vector_types::Gradient;
// Aims for interoperable compatibility with:
// https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#:~:text=%27grdm%27%20%3D%20Gradient%20Map
@@ -14,10 +14,10 @@ fn gradient_map<T: Adjust<Color> + Clone + Send + Sync + core_types::CacheHash +
#[implementations(
Raster<CPU>,
Color,
GradientStops,
Gradient,
)]
mut image: T,
gradient: IList<GradientStops>,
gradient: IList<Gradient>,
reverse: bool,
) -> T {
if gradient.is_empty() {