mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 05:18:19 +00:00
Upgrade to the Rust 2024 edition (#2367)
* Update to rust 2024 edition * Fixes * Clean up imports * Cargo fmt again --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
927d7dd9b2
commit
beb1c6ae64
253 changed files with 980 additions and 1371 deletions
|
@ -2,15 +2,13 @@ use crate::instances::Instances;
|
|||
use crate::text::FontCache;
|
||||
use crate::transform::{Footprint, Transform, TransformMut};
|
||||
use crate::vector::style::ViewMode;
|
||||
|
||||
use dyn_any::{DynAny, StaticType, StaticTypeSized};
|
||||
|
||||
use alloc::sync::Arc;
|
||||
use core::fmt::Debug;
|
||||
use core::future::Future;
|
||||
use core::hash::{Hash, Hasher};
|
||||
use core::pin::Pin;
|
||||
use core::ptr::addr_of;
|
||||
use dyn_any::{DynAny, StaticType, StaticTypeSized};
|
||||
use glam::{DAffine2, UVec2};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::transform::Footprint;
|
||||
|
||||
use core::{any::Any, borrow::Borrow, panic::Location};
|
||||
use core::any::Any;
|
||||
use core::borrow::Borrow;
|
||||
use core::panic::Location;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub trait Ctx: Clone + Send {}
|
||||
|
@ -87,12 +88,12 @@ impl<T: ExtractIndex> ExtractIndex for Option<T> {
|
|||
}
|
||||
impl<T: ExtractVarArgs + Sync> ExtractVarArgs for Option<T> {
|
||||
fn vararg(&self, index: usize) -> Result<DynRef<'_>, VarArgsResult> {
|
||||
let Some(ref inner) = self else { return Err(VarArgsResult::NoVarArgs) };
|
||||
let Some(inner) = self else { return Err(VarArgsResult::NoVarArgs) };
|
||||
inner.vararg(index)
|
||||
}
|
||||
|
||||
fn varargs_len(&self) -> Result<usize, VarArgsResult> {
|
||||
let Some(ref inner) = self else { return Err(VarArgsResult::NoVarArgs) };
|
||||
let Some(inner) = self else { return Err(VarArgsResult::NoVarArgs) };
|
||||
inner.varargs_len()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use core::marker::PhantomData;
|
||||
|
||||
use crate::Node;
|
||||
use core::marker::PhantomData;
|
||||
#[derive(Clone)]
|
||||
pub struct FnNode<T: Fn(I) -> O, I, O>(T, PhantomData<(I, O)>);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{raster::Sample, Color};
|
||||
|
||||
use crate::Color;
|
||||
use crate::raster::Sample;
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use spirv_std::image::{Image2d, SampledImage};
|
||||
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
use crate::application_io::{ImageTexture, TextureFrameTable};
|
||||
use crate::instances::Instances;
|
||||
use crate::raster::image::{Image, ImageFrameTable};
|
||||
use crate::raster::BlendMode;
|
||||
use crate::raster::image::{Image, ImageFrameTable};
|
||||
use crate::transform::TransformMut;
|
||||
use crate::uuid::NodeId;
|
||||
use crate::vector::{VectorData, VectorDataTable};
|
||||
use crate::{CloneVarArgs, Color, Context, Ctx, ExtractAll, OwnedContextImpl};
|
||||
|
||||
use dyn_any::DynAny;
|
||||
|
||||
use glam::{DAffine2, IVec2};
|
||||
use std::hash::Hash;
|
||||
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
mod quad;
|
||||
mod rect;
|
||||
pub use quad::Quad;
|
||||
pub use rect::Rect;
|
||||
|
||||
use crate::raster::image::ImageFrameTable;
|
||||
use crate::raster::{BlendMode, Image};
|
||||
use crate::transform::{Footprint, Transform};
|
||||
use crate::uuid::{generate_uuid, NodeId};
|
||||
use crate::uuid::{NodeId, generate_uuid};
|
||||
use crate::vector::style::{Fill, Stroke, ViewMode};
|
||||
use crate::vector::{PointId, VectorDataTable};
|
||||
use crate::{Artboard, ArtboardGroupTable, Color, GraphicElement, GraphicGroupTable, RasterFrame};
|
||||
|
||||
use base64::Engine;
|
||||
use bezier_rs::Subpath;
|
||||
use dyn_any::DynAny;
|
||||
|
||||
use base64::Engine;
|
||||
use glam::{DAffine2, DMat2, DVec2};
|
||||
use num_traits::Zero;
|
||||
pub use quad::Quad;
|
||||
pub use rect::Rect;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::fmt::Write;
|
||||
#[cfg(feature = "vello")]
|
||||
|
@ -883,7 +881,7 @@ impl GraphicElementRendered for ImageFrameTable<Color> {
|
|||
impl GraphicElementRendered for RasterFrame {
|
||||
fn render_svg(&self, render: &mut SvgRender, render_params: &RenderParams) {
|
||||
match self {
|
||||
RasterFrame::ImageFrame(ref image) => image.render_svg(render, render_params),
|
||||
RasterFrame::ImageFrame(image) => image.render_svg(render, render_params),
|
||||
RasterFrame::TextureFrame(_) => unimplemented!(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use glam::{DAffine2, DVec2};
|
||||
|
||||
use super::Quad;
|
||||
use glam::{DAffine2, DVec2};
|
||||
|
||||
#[derive(Debug, Clone, Default, Copy, PartialEq)]
|
||||
/// An axis aligned rect defined by two vertices.
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
use crate::application_io::TextureFrameTable;
|
||||
use crate::raster::image::{Image, ImageFrameTable};
|
||||
use crate::raster::Pixel;
|
||||
use crate::raster::image::{Image, ImageFrameTable};
|
||||
use crate::transform::{Transform, TransformMut};
|
||||
use crate::uuid::NodeId;
|
||||
use crate::vector::{InstanceId, VectorDataTable};
|
||||
use crate::{AlphaBlending, GraphicElement, RasterFrame};
|
||||
|
||||
use dyn_any::StaticType;
|
||||
|
||||
use glam::DAffine2;
|
||||
use std::hash::Hash;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::vector::VectorDataTable;
|
||||
use crate::Context;
|
||||
use crate::Ctx;
|
||||
use crate::vector::VectorDataTable;
|
||||
use glam::{DAffine2, DVec2};
|
||||
|
||||
#[node_macro::node(category("Debug"))]
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
use crate::{Node, WasmNotSend};
|
||||
|
||||
use dyn_any::DynFuture;
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
use alloc::sync::Arc;
|
||||
use core::future::Future;
|
||||
use core::ops::Deref;
|
||||
use dyn_any::DynFuture;
|
||||
use std::hash::DefaultHasher;
|
||||
use std::sync::Mutex;
|
||||
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
use crate::raster::image::ImageFrameTable;
|
||||
use crate::Ctx;
|
||||
use crate::raster::BlendMode;
|
||||
use crate::raster::image::ImageFrameTable;
|
||||
use crate::registry::types::Percentage;
|
||||
use crate::vector::style::GradientStops;
|
||||
use crate::Ctx;
|
||||
use crate::{Color, Node};
|
||||
|
||||
use math_parser::ast;
|
||||
use math_parser::context::{EvalContext, NothingMap, ValueProvider};
|
||||
use math_parser::value::{Number, Value};
|
||||
|
||||
use core::marker::PhantomData;
|
||||
use core::ops::{Add, Div, Mul, Rem, Sub};
|
||||
use glam::DVec2;
|
||||
use math_parser::ast;
|
||||
use math_parser::context::{EvalContext, NothingMap, ValueProvider};
|
||||
use math_parser::value::{Number, Value};
|
||||
use num_traits::Pow;
|
||||
use rand::{Rng, SeedableRng};
|
||||
|
||||
|
@ -136,11 +134,7 @@ fn modulo<U: Rem<T, Output: Add<T, Output: Rem<T, Output = U::Output>>>, T: Copy
|
|||
modulus: T,
|
||||
always_positive: bool,
|
||||
) -> <U as Rem<T>>::Output {
|
||||
if always_positive {
|
||||
(numerator % modulus + modulus) % modulus
|
||||
} else {
|
||||
numerator % modulus
|
||||
}
|
||||
if always_positive { (numerator % modulus + modulus) % modulus } else { numerator % modulus }
|
||||
}
|
||||
|
||||
/// The exponent operation (^) calculates the result of raising a number to a power.
|
||||
|
@ -198,61 +192,37 @@ fn logarithm<U: num_traits::float::Float>(
|
|||
/// The sine trigonometric function (sin) calculates the ratio of the angle's opposite side length to its hypotenuse length.
|
||||
#[node_macro::node(category("Math: Trig"))]
|
||||
fn sine<U: num_traits::float::Float>(_: impl Ctx, #[implementations(f64, f32)] theta: U, radians: bool) -> U {
|
||||
if radians {
|
||||
theta.sin()
|
||||
} else {
|
||||
theta.to_radians().sin()
|
||||
}
|
||||
if radians { theta.sin() } else { theta.to_radians().sin() }
|
||||
}
|
||||
|
||||
/// The cosine trigonometric function (cos) calculates the ratio of the angle's adjacent side length to its hypotenuse length.
|
||||
#[node_macro::node(category("Math: Trig"))]
|
||||
fn cosine<U: num_traits::float::Float>(_: impl Ctx, #[implementations(f64, f32)] theta: U, radians: bool) -> U {
|
||||
if radians {
|
||||
theta.cos()
|
||||
} else {
|
||||
theta.to_radians().cos()
|
||||
}
|
||||
if radians { theta.cos() } else { theta.to_radians().cos() }
|
||||
}
|
||||
|
||||
/// The tangent trigonometric function (tan) calculates the ratio of the angle's opposite side length to its adjacent side length.
|
||||
#[node_macro::node(category("Math: Trig"))]
|
||||
fn tangent<U: num_traits::float::Float>(_: impl Ctx, #[implementations(f64, f32)] theta: U, radians: bool) -> U {
|
||||
if radians {
|
||||
theta.tan()
|
||||
} else {
|
||||
theta.to_radians().tan()
|
||||
}
|
||||
if radians { theta.tan() } else { theta.to_radians().tan() }
|
||||
}
|
||||
|
||||
/// The inverse sine trigonometric function (asin) calculates the angle whose sine is the specified value.
|
||||
#[node_macro::node(category("Math: Trig"))]
|
||||
fn sine_inverse<U: num_traits::float::Float>(_: impl Ctx, #[implementations(f64, f32)] value: U, radians: bool) -> U {
|
||||
if radians {
|
||||
value.asin()
|
||||
} else {
|
||||
value.asin().to_degrees()
|
||||
}
|
||||
if radians { value.asin() } else { value.asin().to_degrees() }
|
||||
}
|
||||
|
||||
/// The inverse cosine trigonometric function (acos) calculates the angle whose cosine is the specified value.
|
||||
#[node_macro::node(category("Math: Trig"))]
|
||||
fn cosine_inverse<U: num_traits::float::Float>(_: impl Ctx, #[implementations(f64, f32)] value: U, radians: bool) -> U {
|
||||
if radians {
|
||||
value.acos()
|
||||
} else {
|
||||
value.acos().to_degrees()
|
||||
}
|
||||
if radians { value.acos() } else { value.acos().to_degrees() }
|
||||
}
|
||||
|
||||
/// The inverse tangent trigonometric function (atan) calculates the angle whose tangent is the specified value.
|
||||
#[node_macro::node(category("Math: Trig"))]
|
||||
fn tangent_inverse<U: num_traits::float::Float>(_: impl Ctx, #[implementations(f64, f32)] value: U, radians: bool) -> U {
|
||||
if radians {
|
||||
value.atan()
|
||||
} else {
|
||||
value.atan().to_degrees()
|
||||
}
|
||||
if radians { value.atan() } else { value.atan().to_degrees() }
|
||||
}
|
||||
|
||||
/// The inverse tangent trigonometric function (atan2) calculates the angle whose tangent is the ratio of the two specified values.
|
||||
|
@ -265,11 +235,7 @@ fn tangent_inverse_2_argument<U: num_traits::float::Float>(
|
|||
x: U,
|
||||
radians: bool,
|
||||
) -> U {
|
||||
if radians {
|
||||
y.atan2(x)
|
||||
} else {
|
||||
y.atan2(x).to_degrees()
|
||||
}
|
||||
if radians { y.atan2(x) } else { y.atan2(x).to_degrees() }
|
||||
}
|
||||
|
||||
/// The random function (rand) converts a seed into a random number within the specified range, inclusive of the minimum and exclusive of the maximum. The minimum and maximum values are automatically swapped if they are reversed.
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
pub use self::color::{Color, Luma, SRGBA8};
|
||||
use crate::Ctx;
|
||||
use crate::GraphicGroupTable;
|
||||
use crate::raster::image::ImageFrameTable;
|
||||
use crate::registry::types::Percentage;
|
||||
use crate::vector::VectorDataTable;
|
||||
use crate::Ctx;
|
||||
use crate::GraphicGroupTable;
|
||||
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use core::fmt::Debug;
|
||||
use glam::DVec2;
|
||||
|
@ -22,6 +21,7 @@ pub mod color;
|
|||
#[cfg(not(target_arch = "spirv"))]
|
||||
pub mod curve;
|
||||
pub mod discrete_srgb;
|
||||
|
||||
pub use adjustments::*;
|
||||
|
||||
pub trait Linear {
|
||||
|
@ -95,11 +95,7 @@ impl Channel for SRGBGammaFloat {
|
|||
#[inline(always)]
|
||||
fn from_linear<In: Linear>(linear: In) -> Self {
|
||||
let x = linear.to_f32();
|
||||
if x <= 0.0031308 {
|
||||
Self(x * 12.92)
|
||||
} else {
|
||||
Self(1.055 * x.powf(1. / 2.4) - 0.055)
|
||||
}
|
||||
if x <= 0.0031308 { Self(x * 12.92) } else { Self(1.055 * x.powf(1. / 2.4) - 0.055) }
|
||||
}
|
||||
}
|
||||
pub trait RGBPrimaries {
|
||||
|
|
|
@ -6,15 +6,13 @@ use crate::raster::curve::{Curve, CurveManipulatorGroup, ValueMapperNode};
|
|||
use crate::raster::image::{Image, ImageFrameTable};
|
||||
use crate::raster::{Channel, Color, Pixel};
|
||||
use crate::registry::types::{Angle, Percentage, SignedPercentage};
|
||||
use crate::vector::style::GradientStops;
|
||||
use crate::vector::VectorDataTable;
|
||||
use crate::vector::style::GradientStops;
|
||||
use crate::{Ctx, Node};
|
||||
use crate::{GraphicElement, GraphicGroupTable};
|
||||
|
||||
use dyn_any::DynAny;
|
||||
|
||||
use core::cmp::Ordering;
|
||||
use core::fmt::Debug;
|
||||
use dyn_any::DynAny;
|
||||
#[cfg(feature = "serde")]
|
||||
#[cfg(target_arch = "spirv")]
|
||||
use spirv_std::num_traits::float::Float;
|
||||
|
@ -574,11 +572,7 @@ async fn threshold<T: Adjust<Color>>(
|
|||
LuminanceCalculation::MaximumChannels => color.maximum_rgb_channels(),
|
||||
};
|
||||
|
||||
if luminance >= min_luminance && luminance <= max_luminance {
|
||||
Color::WHITE
|
||||
} else {
|
||||
Color::BLACK
|
||||
}
|
||||
if luminance >= min_luminance && luminance <= max_luminance { Color::WHITE } else { Color::BLACK }
|
||||
});
|
||||
image
|
||||
}
|
||||
|
@ -720,7 +714,7 @@ impl Adjust<Color> for Color {
|
|||
}
|
||||
impl Adjust<Color> for Option<Color> {
|
||||
fn adjust(&mut self, map_fn: impl Fn(&Color) -> Color) {
|
||||
if let Some(ref mut v) = self {
|
||||
if let Some(v) = self {
|
||||
*v = map_fn(v)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use dyn_any::DynAny;
|
||||
|
||||
use glam::{DAffine2, DVec2};
|
||||
|
||||
#[cfg_attr(not(target_arch = "spirv"), derive(Debug))]
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
use crate::Color;
|
||||
use crate::graphene_core::raster::image::ImageFrameTable;
|
||||
use crate::raster::Image;
|
||||
use crate::vector::brush_stroke::BrushStroke;
|
||||
use crate::vector::brush_stroke::BrushStyle;
|
||||
use crate::Color;
|
||||
|
||||
use dyn_any::DynAny;
|
||||
|
||||
use core::hash::Hash;
|
||||
use dyn_any::DynAny;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
use super::discrete_srgb::{float_to_srgb_u8, srgb_u8_to_float};
|
||||
use super::{Alpha, AlphaMut, AssociatedAlpha, Luminance, LuminanceMut, Pixel, RGBMut, Rec709Primaries, RGB, SRGB};
|
||||
|
||||
use super::{Alpha, AlphaMut, AssociatedAlpha, Luminance, LuminanceMut, Pixel, RGB, RGBMut, Rec709Primaries, SRGB};
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use core::hash::Hash;
|
||||
use dyn_any::DynAny;
|
||||
use half::f16;
|
||||
#[cfg(target_arch = "spirv")]
|
||||
use spirv_std::num_traits::Euclid;
|
||||
#[cfg(feature = "serde")]
|
||||
#[cfg(target_arch = "spirv")]
|
||||
use spirv_std::num_traits::float::Float;
|
||||
#[cfg(target_arch = "spirv")]
|
||||
use spirv_std::num_traits::Euclid;
|
||||
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use core::hash::Hash;
|
||||
use half::f16;
|
||||
use std::fmt::Write;
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -663,11 +661,7 @@ impl Color {
|
|||
|
||||
#[inline(always)]
|
||||
pub fn blend_darker_color(&self, other: Color) -> Color {
|
||||
if self.average_rgb_channels() <= other.average_rgb_channels() {
|
||||
*self
|
||||
} else {
|
||||
other
|
||||
}
|
||||
if self.average_rgb_channels() <= other.average_rgb_channels() { *self } else { other }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -682,11 +676,7 @@ impl Color {
|
|||
|
||||
#[inline(always)]
|
||||
pub fn blend_color_dodge(c_b: f32, c_s: f32) -> f32 {
|
||||
if c_s == 1. {
|
||||
1.
|
||||
} else {
|
||||
(c_b / (1. - c_s)).min(1.)
|
||||
}
|
||||
if c_s == 1. { 1. } else { (c_b / (1. - c_s)).min(1.) }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -696,11 +686,7 @@ impl Color {
|
|||
|
||||
#[inline(always)]
|
||||
pub fn blend_lighter_color(&self, other: Color) -> Color {
|
||||
if self.average_rgb_channels() >= other.average_rgb_channels() {
|
||||
*self
|
||||
} else {
|
||||
other
|
||||
}
|
||||
if self.average_rgb_channels() >= other.average_rgb_channels() { *self } else { other }
|
||||
}
|
||||
|
||||
pub fn blend_softlight(c_b: f32, c_s: f32) -> f32 {
|
||||
|
@ -745,11 +731,7 @@ impl Color {
|
|||
}
|
||||
|
||||
pub fn blend_hard_mix(c_b: f32, c_s: f32) -> f32 {
|
||||
if Color::blend_linear_light(c_b, c_s) < 0.5 {
|
||||
0.
|
||||
} else {
|
||||
1.
|
||||
}
|
||||
if Color::blend_linear_light(c_b, c_s) < 0.5 { 0. } else { 1. }
|
||||
}
|
||||
|
||||
pub fn blend_difference(c_b: f32, c_s: f32) -> f32 {
|
||||
|
@ -765,11 +747,7 @@ impl Color {
|
|||
}
|
||||
|
||||
pub fn blend_divide(c_b: f32, c_s: f32) -> f32 {
|
||||
if c_b == 0. {
|
||||
1.
|
||||
} else {
|
||||
c_b / c_s
|
||||
}
|
||||
if c_b == 0. { 1. } else { c_b / c_s }
|
||||
}
|
||||
|
||||
pub fn blend_hue(&self, c_s: Color) -> Color {
|
||||
|
@ -988,20 +966,12 @@ impl Color {
|
|||
|
||||
#[inline(always)]
|
||||
pub fn srgb_to_linear(channel: f32) -> f32 {
|
||||
if channel <= 0.04045 {
|
||||
channel / 12.92
|
||||
} else {
|
||||
((channel + 0.055) / 1.055).powf(2.4)
|
||||
}
|
||||
if channel <= 0.04045 { channel / 12.92 } else { ((channel + 0.055) / 1.055).powf(2.4) }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn linear_to_srgb(channel: f32) -> f32 {
|
||||
if channel <= 0.0031308 {
|
||||
channel * 12.92
|
||||
} else {
|
||||
1.055 * channel.powf(1. / 2.4) - 0.055
|
||||
}
|
||||
if channel <= 0.0031308 { channel * 12.92 } else { 1.055 * channel.powf(1. / 2.4) - 0.055 }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
use super::{Channel, Linear, LuminanceMut};
|
||||
use crate::Node;
|
||||
|
||||
use dyn_any::{DynAny, StaticType, StaticTypeSized};
|
||||
|
||||
use core::ops::{Add, Mul, Sub};
|
||||
use dyn_any::{DynAny, StaticType, StaticTypeSized};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, DynAny, specta::Type)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
|
|
|
@ -85,11 +85,7 @@ pub fn float_to_srgb_u8(mut f: f32) -> u8 {
|
|||
let lerp = bias.wrapping_add(mult * lerp_idx) >> 24;
|
||||
|
||||
// Adjust linear interpolation to the correct value.
|
||||
if f > CRITICAL_POINTS[lerp as usize] {
|
||||
lerp as u8 + 1
|
||||
} else {
|
||||
lerp as u8
|
||||
}
|
||||
if f > CRITICAL_POINTS[lerp as usize] { lerp as u8 + 1 } else { lerp as u8 }
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
|
@ -156,11 +152,7 @@ mod tests {
|
|||
|
||||
// https://microsoft.github.io/DirectX-Specs/d3d/archive/D3D11_3_FunctionalSpec.htm#SRGBtoFLOAT
|
||||
fn srgb_to_float_ref(f: f32) -> f32 {
|
||||
if f <= 0.04045f32 {
|
||||
f / 12.92f32
|
||||
} else {
|
||||
((f + 0.055f32) / 1.055f32).powf(2.4_f32)
|
||||
}
|
||||
if f <= 0.04045f32 { f / 12.92f32 } else { ((f + 0.055f32) / 1.055f32).powf(2.4_f32) }
|
||||
}
|
||||
|
||||
fn srgb_u8_to_float_ref(c: u8) -> f32 {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use super::discrete_srgb::float_to_srgb_u8;
|
||||
use super::Color;
|
||||
use crate::instances::Instances;
|
||||
use crate::transform::TransformMut;
|
||||
use super::discrete_srgb::float_to_srgb_u8;
|
||||
use crate::AlphaBlending;
|
||||
use crate::GraphicElement;
|
||||
use crate::instances::Instances;
|
||||
use crate::transform::TransformMut;
|
||||
use alloc::vec::Vec;
|
||||
use core::hash::{Hash, Hasher};
|
||||
use dyn_any::StaticType;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use crate::transform::Footprint;
|
||||
use crate::{Node, NodeIO, NodeIOTypes, Type, WasmNotSend};
|
||||
|
||||
use dyn_any::{DynAny, StaticType};
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::marker::PhantomData;
|
||||
use std::ops::Deref;
|
||||
|
@ -150,7 +148,9 @@ impl NodeContainer {
|
|||
|
||||
#[cfg(feature = "dealloc_nodes")]
|
||||
unsafe fn dealloc_unchecked(&mut self) {
|
||||
std::mem::drop(Box::from_raw(self.node as *mut TypeErasedNode));
|
||||
unsafe {
|
||||
std::mem::drop(Box::from_raw(self.node as *mut TypeErasedNode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use core::marker::PhantomData;
|
||||
|
||||
use crate::Node;
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// This is how we can generically define composition of two nodes.
|
||||
/// This is done generically as shown: <https://files.keavon.com/-/SurprisedGaseousAnhinga/capture.png>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use dyn_any::DynAny;
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// A font type (storing font family and font style and an optional preview URL)
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
use crate::vector::PointId;
|
||||
|
||||
use bezier_rs::{ManipulatorGroup, Subpath};
|
||||
|
||||
use glam::DVec2;
|
||||
use rustybuzz::ttf_parser::{GlyphId, OutlineBuilder};
|
||||
use rustybuzz::{GlyphBuffer, UnicodeBuffer};
|
||||
|
|
|
@ -4,7 +4,6 @@ use crate::raster::bbox::AxisAlignedBbox;
|
|||
use crate::raster::image::ImageFrameTable;
|
||||
use crate::vector::VectorDataTable;
|
||||
use crate::{Artboard, ArtboardGroupTable, CloneVarArgs, Color, Context, Ctx, ExtractAll, GraphicGroupTable, OwnedContextImpl};
|
||||
|
||||
use glam::{DAffine2, DVec2};
|
||||
|
||||
pub trait Transform {
|
||||
|
|
|
@ -29,7 +29,7 @@ macro_rules! concrete {
|
|||
|
||||
#[macro_export]
|
||||
macro_rules! concrete_with_name {
|
||||
($type:ty, $name:expr) => {
|
||||
($type:ty, $name:expr_2021) => {
|
||||
$crate::Type::Concrete($crate::TypeDescriptor {
|
||||
id: Some(core::any::TypeId::of::<$type>()),
|
||||
name: $crate::Cow::Borrowed($name),
|
||||
|
@ -42,16 +42,12 @@ macro_rules! concrete_with_name {
|
|||
|
||||
#[macro_export]
|
||||
macro_rules! generic {
|
||||
($type:ty) => {{
|
||||
$crate::Type::Generic($crate::Cow::Borrowed(stringify!($type)))
|
||||
}};
|
||||
($type:ty) => {{ $crate::Type::Generic($crate::Cow::Borrowed(stringify!($type))) }};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! future {
|
||||
($type:ty) => {{
|
||||
$crate::Type::Future(Box::new(concrete!($type)))
|
||||
}};
|
||||
($type:ty) => {{ $crate::Type::Future(Box::new(concrete!($type))) }};
|
||||
($type:ty, $name:ty) => {
|
||||
$crate::Type::Future(Box::new(concrete!($type, $name)))
|
||||
};
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
pub use uuid_generation::*;
|
||||
|
||||
use dyn_any::DynAny;
|
||||
pub use uuid_generation::*;
|
||||
|
||||
#[derive(Clone, Copy, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct Uuid(
|
||||
|
@ -45,8 +44,8 @@ mod u64_string {
|
|||
|
||||
mod uuid_generation {
|
||||
use core::cell::Cell;
|
||||
use rand_chacha::rand_core::{RngCore, SeedableRng};
|
||||
use rand_chacha::ChaCha20Rng;
|
||||
use rand_chacha::rand_core::{RngCore, SeedableRng};
|
||||
use std::sync::Mutex;
|
||||
|
||||
static RNG: Mutex<Option<ChaCha20Rng>> = Mutex::new(None);
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
use crate::Node;
|
||||
|
||||
use core::{
|
||||
cell::{Cell, RefCell, RefMut},
|
||||
marker::PhantomData,
|
||||
};
|
||||
use core::cell::{Cell, RefCell, RefMut};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
#[derive(Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||
pub struct IntNode<const N: u32>;
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
use crate::raster::bbox::AxisAlignedBbox;
|
||||
use crate::raster::BlendMode;
|
||||
use crate::Color;
|
||||
|
||||
use crate::raster::BlendMode;
|
||||
use crate::raster::bbox::AxisAlignedBbox;
|
||||
use dyn_any::DynAny;
|
||||
|
||||
use glam::DVec2;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::vector::{HandleId, VectorData, VectorDataTable};
|
||||
use crate::Ctx;
|
||||
|
||||
use crate::vector::{HandleId, VectorData, VectorDataTable};
|
||||
use bezier_rs::Subpath;
|
||||
use glam::DVec2;
|
||||
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
pub mod brush_stroke;
|
||||
pub mod generator_nodes;
|
||||
pub mod misc;
|
||||
|
||||
pub mod style;
|
||||
pub use style::PathStyle;
|
||||
|
||||
mod vector_data;
|
||||
pub use vector_data::*;
|
||||
|
||||
mod vector_nodes;
|
||||
pub use vector_nodes::*;
|
||||
|
||||
pub use bezier_rs;
|
||||
pub use style::PathStyle;
|
||||
pub use vector_data::*;
|
||||
pub use vector_nodes::*;
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
//! Contains stylistic options for SVG elements.
|
||||
|
||||
use crate::Color;
|
||||
use crate::consts::{LAYER_OUTLINE_STROKE_COLOR, LAYER_OUTLINE_STROKE_WEIGHT};
|
||||
use crate::renderer::format_transform_matrix;
|
||||
use crate::Color;
|
||||
|
||||
use dyn_any::DynAny;
|
||||
|
||||
use glam::{DAffine2, DVec2};
|
||||
use std::fmt::{self, Display, Write};
|
||||
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
mod attributes;
|
||||
mod modification;
|
||||
pub use attributes::*;
|
||||
pub use modification::*;
|
||||
|
||||
use super::style::{PathStyle, Stroke};
|
||||
use crate::instances::Instances;
|
||||
use crate::{AlphaBlending, Color, GraphicGroupTable};
|
||||
|
||||
pub use attributes::*;
|
||||
use bezier_rs::ManipulatorGroup;
|
||||
use dyn_any::DynAny;
|
||||
|
||||
use core::borrow::Borrow;
|
||||
use dyn_any::DynAny;
|
||||
use glam::{DAffine2, DVec2};
|
||||
pub use modification::*;
|
||||
use std::collections::HashMap;
|
||||
|
||||
// TODO: Eventually remove this migration document upgrade code
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
use crate::vector::vector_data::{HandleId, VectorData};
|
||||
|
||||
use dyn_any::DynAny;
|
||||
|
||||
use glam::{DAffine2, DVec2};
|
||||
use std::collections::HashMap;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
@ -218,7 +216,7 @@ impl SegmentDomain {
|
|||
.zip(&self.start_point)
|
||||
.zip(&self.end_point)
|
||||
.filter(|((_, start), end)| **start >= points_length || **end >= points_length)
|
||||
.map(|x| *x.0 .0)
|
||||
.map(|x| *x.0.0)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let can_delete = || {
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
use super::*;
|
||||
use crate::Ctx;
|
||||
use crate::transform::TransformMut;
|
||||
use crate::uuid::generate_uuid;
|
||||
use crate::Ctx;
|
||||
|
||||
use bezier_rs::BezierHandles;
|
||||
use dyn_any::DynAny;
|
||||
|
||||
use core::hash::BuildHasher;
|
||||
use dyn_any::DynAny;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
/// Represents a procedural change to the [`PointDomain`] in [`VectorData`].
|
||||
|
|
|
@ -5,10 +5,9 @@ use crate::instances::{InstanceMut, Instances};
|
|||
use crate::registry::types::{Angle, Fraction, IntegerCount, Length, SeedValue};
|
||||
use crate::renderer::GraphicElementRendered;
|
||||
use crate::transform::{Footprint, Transform, TransformMut};
|
||||
use crate::vector::style::LineJoin;
|
||||
use crate::vector::PointDomain;
|
||||
use crate::vector::style::LineJoin;
|
||||
use crate::{CloneVarArgs, Color, Context, Ctx, ExtractAll, GraphicElement, GraphicGroupTable, OwnedContextImpl};
|
||||
|
||||
use bezier_rs::{Cap, Join, Subpath, SubpathTValue, TValue};
|
||||
use glam::{DAffine2, DVec2};
|
||||
use rand::{Rng, SeedableRng};
|
||||
|
@ -1067,9 +1066,7 @@ async fn centroid(ctx: impl Ctx + CloneVarArgs + ExtractAll, vector_data: impl N
|
|||
mod test {
|
||||
use super::*;
|
||||
use crate::Node;
|
||||
|
||||
use bezier_rs::Bezier;
|
||||
|
||||
use std::pin::Pin;
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue