mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Remove dead code from the unused curves adjustment widget
This commit is contained in:
@@ -11,15 +11,6 @@ pub trait Linear {
|
||||
fn to_f32(self) -> f32;
|
||||
fn from_f64(x: f64) -> Self;
|
||||
fn to_f64(self) -> f64;
|
||||
fn lerp(self, other: Self, value: Self) -> Self
|
||||
where
|
||||
Self: Sized + Copy,
|
||||
Self: core::ops::Sub<Self, Output = Self>,
|
||||
Self: core::ops::Mul<Self, Output = Self>,
|
||||
Self: core::ops::Add<Self, Output = Self>,
|
||||
{
|
||||
self + (other - self) * value
|
||||
}
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
@@ -174,10 +165,6 @@ pub trait Luminance {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait LuminanceMut: Luminance {
|
||||
fn set_luminance(&mut self, luminance: Self::LuminanceChannel);
|
||||
}
|
||||
|
||||
// TODO: We might rename this to Raster at some point
|
||||
pub trait Sample {
|
||||
type Pixel: Pixel;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::color_traits::{Alpha, AlphaMut, AssociatedAlpha, Luminance, LuminanceMut, Pixel, RGB, RGBMut, Rec709Primaries, SRGB};
|
||||
use super::color_traits::{Alpha, AlphaMut, AssociatedAlpha, Luminance, Pixel, RGB, RGBMut, Rec709Primaries, SRGB};
|
||||
use super::discrete_srgb::{float_to_srgb_u8, srgb_u8_to_float};
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use core::fmt::Debug;
|
||||
@@ -236,12 +236,6 @@ impl Luminance for Luma {
|
||||
}
|
||||
}
|
||||
|
||||
impl LuminanceMut for Luma {
|
||||
fn set_luminance(&mut self, luminance: Self::LuminanceChannel) {
|
||||
self.0 = luminance
|
||||
}
|
||||
}
|
||||
|
||||
impl RGB for Luma {
|
||||
type ColorChannel = f32;
|
||||
#[inline(always)]
|
||||
@@ -411,28 +405,6 @@ impl Luminance for Color {
|
||||
}
|
||||
}
|
||||
|
||||
impl LuminanceMut for Color {
|
||||
fn set_luminance(&mut self, luminance: f32) {
|
||||
let current = self.luminance();
|
||||
// When we have a black-ish color, we just set the color to a grey-scale value. This prohibits a divide-by-0.
|
||||
if current < f32::EPSILON {
|
||||
self.red = 0.2126 * luminance;
|
||||
self.green = 0.7152 * luminance;
|
||||
self.blue = 0.0722 * luminance;
|
||||
return;
|
||||
}
|
||||
let fac = luminance / current;
|
||||
// TODO: when we have for example the rgb color (0, 0, 1) and want to
|
||||
// TODO: do `.set_luminance(1)`, then the actual luminance is not 1 at
|
||||
// TODO: the end. With no clamp, the resulting color would be
|
||||
// TODO: (0, 0, 12.8504). The excess should be spread to the other
|
||||
// TODO: channels, but is currently just clamped away.
|
||||
self.red = (self.red * fac).clamp(0., 1.);
|
||||
self.green = (self.green * fac).clamp(0., 1.);
|
||||
self.blue = (self.blue * fac).clamp(0., 1.);
|
||||
}
|
||||
}
|
||||
|
||||
impl Rec709Primaries for Color {}
|
||||
impl SRGB for Color {}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ use crate::vector::algorithms::offset_subpath::MAX_ABSOLUTE_DIFFERENCE;
|
||||
use crate::vector::misc::{PointSpacingType, dvec2_to_point, point_to_dvec2};
|
||||
use core_types::math::polynomial::pathseg_to_parametric_polynomial;
|
||||
use glam::{DMat2, DVec2};
|
||||
use kurbo::common::{solve_cubic, solve_quadratic};
|
||||
use kurbo::{BezPath, CubicBez, DEFAULT_ACCURACY, Line, ParamCurve, ParamCurveArclen, ParamCurveDeriv, PathEl, PathSeg, Point, QuadBez, Rect, Shape, Vec2};
|
||||
use std::f64::consts::{FRAC_PI_2, PI};
|
||||
|
||||
@@ -201,39 +200,6 @@ pub fn pathseg_compute_lookup_table(segment: PathSeg, steps: Option<usize>, eucl
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns an `Iterator` containing all possible parametric `t`-values at the given `x`-coordinate.
|
||||
pub fn pathseg_find_tvalues_for_x(segment: PathSeg, x: f64) -> impl Iterator<Item = f64> + use<> {
|
||||
match segment {
|
||||
PathSeg::Line(Line { p0, p1 }) => {
|
||||
// If the transformed linear bezier is on the x-axis, `a` and `b` will both be zero and `solve_linear` will return no roots
|
||||
let a = p1.x - p0.x;
|
||||
let b = p0.x - x;
|
||||
|
||||
// Find the roots of the linear equation `ax + b`.
|
||||
// There exist roots when `a` is not 0
|
||||
if a.abs() > MAX_ABSOLUTE_DIFFERENCE { [Some(-b / a), None, None] } else { [None; 3] }
|
||||
}
|
||||
PathSeg::Quad(QuadBez { p0, p1, p2 }) => {
|
||||
let a = p2.x - 2. * p1.x + p0.x;
|
||||
let b = 2. * (p1.x - p0.x);
|
||||
let c = p0.x - x;
|
||||
let r = solve_quadratic(c, b, a);
|
||||
[r.first().copied(), r.get(1).copied(), None]
|
||||
}
|
||||
PathSeg::Cubic(CubicBez { p0, p1, p2, p3 }) => {
|
||||
let a = p3.x - 3. * p2.x + 3. * p1.x - p0.x;
|
||||
let b = 3. * (p2.x - 2. * p1.x + p0.x);
|
||||
let c = 3. * (p1.x - p0.x);
|
||||
let d = p0.x - x;
|
||||
let r = solve_cubic(d, c, b, a);
|
||||
[r.first().copied(), r.get(1).copied(), r.get(2).copied()]
|
||||
}
|
||||
}
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.filter(|&t| (0.0..1.).contains(&t))
|
||||
}
|
||||
|
||||
/// Find the `t`-value(s) such that the normal(s) at `t` pass through the specified point.
|
||||
pub fn pathseg_normals_to_point(segment: PathSeg, point: Point) -> Vec<f64> {
|
||||
// We solve deriv(t) dot (self(t) - point) = 0.
|
||||
|
||||
Reference in New Issue
Block a user