mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Merge origin/master into the async record refactor
Scaffolding merge for the reconcile; the final series to master is authored fresh. Rank plumbing resolves to our axis-IR model, the node macro and the LaneSource render walk stay ours, master's vector restructure and gradient vocabulary are adopted, and the paint and appearance adoption is deliberately deferred behind our fill and stroke markers.
This commit is contained in:
@@ -6,10 +6,9 @@ use core_types::gpoll::{Extent, GPoll, Interrupt};
|
||||
use core_types::transform::{ApplyTransform, ScaleType, Transform};
|
||||
use core_types::{CacheHash, Context, Ctx, DeriveCtx, InjectFootprint, ModifyFootprint};
|
||||
use glam::{DAffine2, DMat2, DVec2};
|
||||
use graphic_types::Graphic;
|
||||
use graphic_types::Vector;
|
||||
use graphic_types::raster_types::{CPU, GPU, Raster};
|
||||
use vector_types::GradientStops;
|
||||
use graphic_types::{Artboard, Graphic, Vector};
|
||||
use vector_types::Gradient;
|
||||
|
||||
/// Applies the specified transform to each lane of the input, composing onto the lane's transform attribute.
|
||||
#[node_macro::node(category("Math: Transform"), extent(transform_extent))]
|
||||
@@ -57,7 +56,7 @@ fn transform_value<T: ApplyTransform + 'static>(
|
||||
let transformed = ctx.modify_footprint(|footprint| footprint.apply_transform(&matrix));
|
||||
let mut transform_target = content.eval(&transformed.ctx())?;
|
||||
|
||||
transform_target.left_apply_transform(&matrix);
|
||||
item.left_apply_transform(&matrix);
|
||||
|
||||
Ok(transform_target)
|
||||
}
|
||||
@@ -97,7 +96,7 @@ fn replace_transform<T>(_: impl Ctx + InjectFootprint, (element, _content_transf
|
||||
// TODO: Figure out how this node should behave once #2982 is implemented.
|
||||
/// Obtains the transform of the first lane of the input, if present.
|
||||
#[node_macro::node(category("Math: Transform"), path(core_types::vector))]
|
||||
fn extract_transform<T: Clone + Send + Sync + CacheHash + 'static>(_: impl Ctx, #[implementations(Graphic, Vector, Raster<CPU>, Raster<GPU>, Color, GradientStops)] content: IList<T>) -> DAffine2 {
|
||||
fn extract_transform<T: Clone + Send + Sync + CacheHash + 'static>(_: impl Ctx, #[implementations(Graphic, Vector, Raster<CPU>, Raster<GPU>, Color, Gradient)] content: IList<T>) -> DAffine2 {
|
||||
match content.len() {
|
||||
0 => DAffine2::default(),
|
||||
_ => content.lane(0).attr::<TransformAttr>(),
|
||||
@@ -107,19 +106,23 @@ fn extract_transform<T: Clone + Send + Sync + CacheHash + 'static>(_: impl Ctx,
|
||||
/// Produces the inverse of the input transform, which is the transform that undoes the effect of the original transform.
|
||||
#[node_macro::node(category("Math: Transform"))]
|
||||
fn invert_transform(_: impl Ctx, transform: DAffine2) -> DAffine2 {
|
||||
transform.inverse()
|
||||
let (transform, attributes) = transform.into_parts();
|
||||
|
||||
let result = transform.inverse();
|
||||
|
||||
Item::from_parts(result, attributes)
|
||||
}
|
||||
|
||||
/// Extracts the translation component from the input transform.
|
||||
#[node_macro::node(category("Math: Transform"))]
|
||||
fn decompose_translation(_: impl Ctx, transform: DAffine2) -> DVec2 {
|
||||
transform.translation
|
||||
Item::new_from_element(transform.into_element().translation)
|
||||
}
|
||||
|
||||
/// Extracts the rotation component (in degrees) from the input transform.
|
||||
#[node_macro::node(category("Math: Transform"))]
|
||||
fn decompose_rotation(_: impl Ctx, transform: DAffine2) -> f64 {
|
||||
transform.decompose_rotation().to_degrees()
|
||||
Item::new_from_element(transform.into_element().decompose_rotation().to_degrees())
|
||||
}
|
||||
|
||||
/// Extracts the scale component from the input transform.
|
||||
@@ -127,14 +130,19 @@ fn decompose_rotation(_: impl Ctx, transform: DAffine2) -> f64 {
|
||||
/// **Pure** returns the isolated scale factors with rotation and skew stripped away (can be negative for flipped axes).
|
||||
#[node_macro::node(category("Math: Transform"))]
|
||||
fn decompose_scale(_: impl Ctx, transform: DAffine2, scale_type: ScaleType) -> DVec2 {
|
||||
match scale_type {
|
||||
let transform = transform.into_element();
|
||||
let scale_type = scale_type.into_element();
|
||||
|
||||
let result = match scale_type {
|
||||
ScaleType::Magnitude => transform.scale_magnitudes(),
|
||||
ScaleType::Pure => transform.decompose_scale(),
|
||||
}
|
||||
};
|
||||
|
||||
Item::new_from_element(result)
|
||||
}
|
||||
|
||||
/// Extracts the skew angle (in degrees) from the input transform.
|
||||
#[node_macro::node(category("Math: Transform"))]
|
||||
fn decompose_skew(_: impl Ctx, transform: DAffine2) -> f64 {
|
||||
transform.decompose_skew().atan().to_degrees()
|
||||
Item::new_from_element(transform.into_element().decompose_skew().atan().to_degrees())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user