mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-27 09:08:13 +08:00
Cargo fmt
This commit is contained in:
@@ -14,7 +14,9 @@ use crate::{NetworkId, NodeMetadataSource, PeerId, Position, Registry};
|
|||||||
/// Test networks with Import inputs will fail compilation (which is expected).
|
/// Test networks with Import inputs will fail compilation (which is expected).
|
||||||
fn verify_network_compiles(network: &NodeNetwork) -> Result<(), String> {
|
fn verify_network_compiles(network: &NodeNetwork) -> Result<(), String> {
|
||||||
let compiler = Compiler {};
|
let compiler = Compiler {};
|
||||||
compiler.compile_single(network.clone(), &graph_craft::proto::Registry::new()).map_err(|e| format!("Compilation failed: {:?}", e))?;
|
compiler
|
||||||
|
.compile_single(network.clone(), &graph_craft::proto::Registry::new())
|
||||||
|
.map_err(|e| format!("Compilation failed: {:?}", e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2743,10 +2743,7 @@ pub fn stroke_properties(node_id: NodeId, context: &mut NodePropertiesContext) -
|
|||||||
.for_socket(ParameterWidgetsInfo::new(node_id, PaintOrderInput::INDEX, true, context))
|
.for_socket(ParameterWidgetsInfo::new(node_id, PaintOrderInput::INDEX, true, context))
|
||||||
.property_row();
|
.property_row();
|
||||||
let disabled_number_input = NumberInput::default().unit(" px").disabled(has_dash_lengths);
|
let disabled_number_input = NumberInput::default().unit(" px").disabled(has_dash_lengths);
|
||||||
let dash_lengths = array_of_number_widget(
|
let dash_lengths = array_of_number_widget(ParameterWidgetsInfo::new(node_id, DashLengthsInput::INDEX, true, context), TextInput::default().centered(true));
|
||||||
ParameterWidgetsInfo::new(node_id, DashLengthsInput::INDEX, true, context),
|
|
||||||
TextInput::default().centered(true),
|
|
||||||
);
|
|
||||||
let number_input = disabled_number_input;
|
let number_input = disabled_number_input;
|
||||||
let dash_offset = number_widget(ParameterWidgetsInfo::new(node_id, DashOffsetInput::INDEX, true, context), number_input);
|
let dash_offset = number_widget(ParameterWidgetsInfo::new(node_id, DashOffsetInput::INDEX, true, context), number_input);
|
||||||
|
|
||||||
|
|||||||
@@ -2012,10 +2012,10 @@ mod test_gradient {
|
|||||||
pub use crate::test_utils::test_prelude::*;
|
pub use crate::test_utils::test_prelude::*;
|
||||||
use glam::DAffine2;
|
use glam::DAffine2;
|
||||||
use graph_craft::document::value::TaggedValue;
|
use graph_craft::document::value::TaggedValue;
|
||||||
|
use graphene_std::NodeInputDecleration;
|
||||||
use graphene_std::color::SRGBA8;
|
use graphene_std::color::SRGBA8;
|
||||||
use graphene_std::vector::style::{GradientSpreadMethod, build_transform_with_y_preservation};
|
use graphene_std::vector::style::{GradientSpreadMethod, build_transform_with_y_preservation};
|
||||||
use graphene_std::vector::{GradientStop, GradientStops, fill};
|
use graphene_std::vector::{GradientStop, GradientStops, fill};
|
||||||
use graphene_std::NodeInputDecleration;
|
|
||||||
|
|
||||||
use super::gradient_space_transform;
|
use super::gradient_space_transform;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ fn compile_to_proto(c: &mut Criterion) {
|
|||||||
|
|
||||||
for name in DEMO_ART {
|
for name in DEMO_ART {
|
||||||
let network = load_from_name(name);
|
let network = load_from_name(name);
|
||||||
c.bench_function(name, |b| b.iter_batched(|| network.clone(), |network| compile(black_box(network), registry), criterion::BatchSize::SmallInput));
|
c.bench_function(name, |b| {
|
||||||
|
b.iter_batched(|| network.clone(), |network| compile(black_box(network), registry), criterion::BatchSize::SmallInput)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -382,8 +382,10 @@ impl ProtoNetwork {
|
|||||||
layout,
|
layout,
|
||||||
}),
|
}),
|
||||||
ConstructionArgs::Nodes(inputs) => node.resolved.layout_meta.as_ref().and_then(|meta| {
|
ConstructionArgs::Nodes(inputs) => node.resolved.layout_meta.as_ref().and_then(|meta| {
|
||||||
let input_layouts: Vec<Option<&core_types::record::Layout>> =
|
let input_layouts: Vec<Option<&core_types::record::Layout>> = inputs
|
||||||
inputs.iter().map(|input| self.nodes[input.0 as usize].1.resolved.layout.as_ref().map(|resolved| &resolved.layout)).collect();
|
.iter()
|
||||||
|
.map(|input| self.nodes[input.0 as usize].1.resolved.layout.as_ref().map(|resolved| &resolved.layout))
|
||||||
|
.collect();
|
||||||
meta.sources.iter().all(|&source| input_layouts[source as usize].is_some()).then(|| meta.resolve(&input_layouts))
|
meta.sources.iter().all(|&source| input_layouts[source as usize].is_some()).then(|| meta.resolve(&input_layouts))
|
||||||
}),
|
}),
|
||||||
ConstructionArgs::Inline(_) => None,
|
ConstructionArgs::Inline(_) => None,
|
||||||
@@ -1042,13 +1044,7 @@ fn check_generic(types: &NodeIOTypes, input: &Type, parameters: &[Type], generic
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(types.inputs.iter().map(|x| x.fn_input()).zip(parameters.iter().map(|x| x.fn_input())))
|
.chain(types.inputs.iter().map(|x| x.fn_input()).zip(parameters.iter().map(|x| x.fn_input())))
|
||||||
.chain(types.inputs.iter().map(|x| x.fn_output()).zip(parameters.iter().map(|x| x.fn_output())))
|
.chain(types.inputs.iter().map(|x| x.fn_output()).zip(parameters.iter().map(|x| x.fn_output())))
|
||||||
.chain(
|
.chain(types.inputs.iter().map(|x| record_element(x.fn_output())).zip(parameters.iter().map(|x| record_element(x.fn_output()))));
|
||||||
types
|
|
||||||
.inputs
|
|
||||||
.iter()
|
|
||||||
.map(|x| record_element(x.fn_output()))
|
|
||||||
.zip(parameters.iter().map(|x| record_element(x.fn_output()))),
|
|
||||||
);
|
|
||||||
let concrete_inputs = inputs.filter(|(ni, _)| matches!(ni, Some(Type::Generic(input)) if generic == input));
|
let concrete_inputs = inputs.filter(|(ni, _)| matches!(ni, Some(Type::Generic(input)) if generic == input));
|
||||||
let mut outputs = concrete_inputs.flat_map(|(_, out)| out);
|
let mut outputs = concrete_inputs.flat_map(|(_, out)| out);
|
||||||
let out_ty = outputs
|
let out_ty = outputs
|
||||||
@@ -1090,10 +1086,7 @@ mod test {
|
|||||||
ProtoNode {
|
ProtoNode {
|
||||||
construction_args: args,
|
construction_args: args,
|
||||||
resolved: Resolved {
|
resolved: Resolved {
|
||||||
layout: Some(core_types::record::RecordLayout {
|
layout: Some(core_types::record::RecordLayout { frame_bytes: 1, ..Default::default() }),
|
||||||
frame_bytes: 1,
|
|
||||||
..Default::default()
|
|
||||||
}),
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|||||||
@@ -358,7 +358,6 @@ impl ContextDependencies {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn sources(&self) -> &[SourceId] {
|
pub fn sources(&self) -> &[SourceId] {
|
||||||
&self.sources
|
&self.sources
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -268,8 +268,8 @@ impl Layout {
|
|||||||
align: field.align,
|
align: field.align,
|
||||||
read_erased: field.read_erased,
|
read_erased: field.read_erased,
|
||||||
repark: field.repark,
|
repark: field.repark,
|
||||||
content_hash: field.content_hash,
|
content_hash: field.content_hash,
|
||||||
content_eq: field.content_eq,
|
content_eq: field.content_eq,
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
union = union.with_writes(union.depth, union.element, &writes);
|
union = union.with_writes(union.depth, union.element, &writes);
|
||||||
@@ -818,14 +818,7 @@ impl<'a, El: Clone, N> ElementLazyInput<'a, El, N> {
|
|||||||
impl<'a, Out, N> ElementLazyInput<'a, Out, N> {
|
impl<'a, Out, N> ElementLazyInput<'a, Out, N> {
|
||||||
/// `read` must be sound against the layout the offsets in `reads` were
|
/// `read` must be sound against the layout the offsets in `reads` were
|
||||||
/// resolved from; the macro proves both at wiring.
|
/// resolved from; the macro proves both at wiring.
|
||||||
pub fn with_reads(
|
pub fn with_reads(node: &'a N, cell: &'a crate::node::StatusCell, input_index: usize, layout: &'a Layout, reads: &'a [Option<usize>], read: unsafe fn(Rec, &[Option<usize>]) -> Out) -> Self {
|
||||||
node: &'a N,
|
|
||||||
cell: &'a crate::node::StatusCell,
|
|
||||||
input_index: usize,
|
|
||||||
layout: &'a Layout,
|
|
||||||
reads: &'a [Option<usize>],
|
|
||||||
read: unsafe fn(Rec, &[Option<usize>]) -> Out,
|
|
||||||
) -> Self {
|
|
||||||
Self {
|
Self {
|
||||||
node,
|
node,
|
||||||
cell,
|
cell,
|
||||||
@@ -1350,7 +1343,6 @@ pub unsafe fn read_element<T: Clone>(rec: Rec) -> T {
|
|||||||
unsafe { borrow_element::<T>(rec) }.clone()
|
unsafe { borrow_element::<T>(rec) }.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// `dst` must be fresh element storage of a record whose element is `T`.
|
/// `dst` must be fresh element storage of a record whose element is `T`.
|
||||||
/// `None` reports arena exhaustion for a parked element.
|
/// `None` reports arena exhaustion for a parked element.
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ use core_types::attribute::{Attr, BlendMode as BlendModeAttr, ClippingMask, Opac
|
|||||||
use core_types::registry::types::Percentage;
|
use core_types::registry::types::Percentage;
|
||||||
use core_types::{BlendMode, Ctx};
|
use core_types::{BlendMode, Ctx};
|
||||||
|
|
||||||
|
|
||||||
/// Applies the blend mode to the input graphics. Setting this allows for customizing how overlapping content is composited together.
|
/// Applies the blend mode to the input graphics. Setting this allows for customizing how overlapping content is composited together.
|
||||||
#[node_macro::node(category("Blending"))]
|
#[node_macro::node(category("Blending"))]
|
||||||
fn blend_mode<T>(
|
fn blend_mode<T>(
|
||||||
|
|||||||
@@ -5,14 +5,14 @@
|
|||||||
//! tests; the node forms are the production authoring surface, and the
|
//! tests; the node forms are the production authoring surface, and the
|
||||||
//! wiring is by hand until the compiler pass constructs layouts.
|
//! wiring is by hand until the compiler pass constructs layouts.
|
||||||
|
|
||||||
|
use core_types::Ctx;
|
||||||
use core_types::attribute::{Attr, EditorLayerPath, Opacity, RemoveAttr, Transform};
|
use core_types::attribute::{Attr, EditorLayerPath, Opacity, RemoveAttr, Transform};
|
||||||
use glam::DAffine2;
|
|
||||||
use core_types::context::{DeriveCtx, ExtractIndex, ExtractIndices, IndexLink, InjectIndex};
|
use core_types::context::{DeriveCtx, ExtractIndex, ExtractIndices, IndexLink, InjectIndex};
|
||||||
use core_types::extent::{ExtentIn, LevelIn, ListIn, ValueIn};
|
use core_types::extent::{ExtentIn, LevelIn, ListIn, ValueIn};
|
||||||
use core_types::gpoll::{ErrorKind, Extent, GPoll, GraphError, Interrupt, Level};
|
use core_types::gpoll::{ErrorKind, Extent, GPoll, GraphError, Interrupt, Level};
|
||||||
use core_types::node::Lane;
|
use core_types::node::Lane;
|
||||||
use core_types::uuid::NodeId;
|
use core_types::uuid::NodeId;
|
||||||
use core_types::Ctx;
|
use glam::DAffine2;
|
||||||
|
|
||||||
core_types::attribute! {
|
core_types::attribute! {
|
||||||
/// Test-only measured length of an element.
|
/// Test-only measured length of an element.
|
||||||
@@ -116,11 +116,7 @@ fn repeat_extent(content: ExtentIn<'_>, count: ValueIn<'_, u32>, _reverse: Value
|
|||||||
/// Test-only lazy-carrier creator: each copy evaluates the content at its own
|
/// Test-only lazy-carrier creator: each copy evaluates the content at its own
|
||||||
/// index and re-scales the row's opacity by the copy number.
|
/// index and re-scales the row's opacity by the copy number.
|
||||||
#[node_macro::node(category("Test"), extent(repeat_faded_extent))]
|
#[node_macro::node(category("Test"), extent(repeat_faded_extent))]
|
||||||
fn repeat_faded<T>(
|
fn repeat_faded<T>(ctx: impl Ctx + DeriveCtx + ExtractIndex, content: impl Node<Context<'_>, Output = (T, Attr<Opacity>)>, count: u32) -> Result<IList<(T, Attr<Opacity>)>, Interrupt> {
|
||||||
ctx: impl Ctx + DeriveCtx + ExtractIndex,
|
|
||||||
content: impl Node<Context<'_>, Output = (T, Attr<Opacity>)>,
|
|
||||||
count: u32,
|
|
||||||
) -> Result<IList<(T, Attr<Opacity>)>, Interrupt> {
|
|
||||||
let inner = content.inner_extent(ctx)?;
|
let inner = content.inner_extent(ctx)?;
|
||||||
let (copy, rest) = ctx.split_innermost(inner);
|
let (copy, rest) = ctx.split_innermost(inner);
|
||||||
if copy >= count as u64 {
|
if copy >= count as u64 {
|
||||||
@@ -143,11 +139,7 @@ fn repeat_faded_extent(content: ExtentIn<'_>, count: ValueIn<'_, u32>, level: Le
|
|||||||
/// Rank-model Extend: the output's top level is `base`'s lanes followed by
|
/// Rank-model Extend: the output's top level is `base`'s lanes followed by
|
||||||
/// `new`'s, each side evaluated within its own index range.
|
/// `new`'s, each side evaluated within its own index range.
|
||||||
#[node_macro::node(category("Test"), extent(extend_extent))]
|
#[node_macro::node(category("Test"), extent(extend_extent))]
|
||||||
fn extend<T>(
|
fn extend<T>(ctx: impl Ctx + ExtractIndex + InjectIndex + Copy, base: impl Node<Context<'_>, Output = T>, new: impl Node<Context<'_>, Output = T>) -> Result<T, Interrupt> {
|
||||||
ctx: impl Ctx + ExtractIndex + InjectIndex + Copy,
|
|
||||||
base: impl Node<Context<'_>, Output = T>,
|
|
||||||
new: impl Node<Context<'_>, Output = T>,
|
|
||||||
) -> Result<T, Interrupt> {
|
|
||||||
let split = match base.extent(ctx, Level::Total) {
|
let split = match base.extent(ctx, Level::Total) {
|
||||||
GPoll::Final(Extent::Exactly(count)) => count as u64,
|
GPoll::Final(Extent::Exactly(count)) => count as u64,
|
||||||
// A scalar side joins the concat as a single lane, per `Extent::sum`.
|
// A scalar side joins the concat as a single lane, per `Extent::sum`.
|
||||||
@@ -375,12 +367,7 @@ async fn double_async(_: impl Ctx, element: f64) -> f64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[node_macro::node(category("Test"))]
|
#[node_macro::node(category("Test"))]
|
||||||
fn fallback(
|
fn fallback(ctx: impl Ctx, _: (), #[expose] content: impl Node<Context<'_>, Output = (f64, Attr<Opacity>)>, #[expose] alternate: impl Node<Context<'_>, Output = f64>) -> Result<f64, Interrupt> {
|
||||||
ctx: impl Ctx,
|
|
||||||
_: (),
|
|
||||||
#[expose] content: impl Node<Context<'_>, Output = (f64, Attr<Opacity>)>,
|
|
||||||
#[expose] alternate: impl Node<Context<'_>, Output = f64>,
|
|
||||||
) -> Result<f64, Interrupt> {
|
|
||||||
let (element, opacity) = content.eval(ctx)?;
|
let (element, opacity) = content.eval(ctx)?;
|
||||||
Ok(if *opacity > 0. { element } else { alternate.eval(ctx)? })
|
Ok(if *opacity > 0. { element } else { alternate.eval(ctx)? })
|
||||||
}
|
}
|
||||||
@@ -747,7 +734,14 @@ mod tests {
|
|||||||
folded: None,
|
folded: None,
|
||||||
};
|
};
|
||||||
let repeat = install(
|
let repeat = install(
|
||||||
RepeatNode::new(RecordSource::new(IndexSourceNode { layout: base.clone() }, &base, &base), count_edge, reverse_edge, &base, &count_layout, &reverse_layout),
|
RepeatNode::new(
|
||||||
|
RecordSource::new(IndexSourceNode { layout: base.clone() }, &base, &base),
|
||||||
|
count_edge,
|
||||||
|
reverse_edge,
|
||||||
|
&base,
|
||||||
|
&count_layout,
|
||||||
|
&reverse_layout,
|
||||||
|
),
|
||||||
meta,
|
meta,
|
||||||
&[Some(&base)],
|
&[Some(&base)],
|
||||||
);
|
);
|
||||||
@@ -789,7 +783,14 @@ mod tests {
|
|||||||
folded: None,
|
folded: None,
|
||||||
};
|
};
|
||||||
let repeat = install(
|
let repeat = install(
|
||||||
RepeatNode::new(RecordSource::new(IndexSourceNode { layout: base.clone() }, &base, &base), count_edge, reverse_edge, &base, &count_layout, &reverse_layout),
|
RepeatNode::new(
|
||||||
|
RecordSource::new(IndexSourceNode { layout: base.clone() }, &base, &base),
|
||||||
|
count_edge,
|
||||||
|
reverse_edge,
|
||||||
|
&base,
|
||||||
|
&count_layout,
|
||||||
|
&reverse_layout,
|
||||||
|
),
|
||||||
meta,
|
meta,
|
||||||
&[Some(&base)],
|
&[Some(&base)],
|
||||||
);
|
);
|
||||||
@@ -833,7 +834,14 @@ mod tests {
|
|||||||
folded: None,
|
folded: None,
|
||||||
};
|
};
|
||||||
let repeat = install(
|
let repeat = install(
|
||||||
RepeatNode::new(RecordSource::new(content, &leveled_content, &leveled_content), count_edge, reverse_edge, &leveled_content, &count_layout, &reverse_layout),
|
RepeatNode::new(
|
||||||
|
RecordSource::new(content, &leveled_content, &leveled_content),
|
||||||
|
count_edge,
|
||||||
|
reverse_edge,
|
||||||
|
&leveled_content,
|
||||||
|
&count_layout,
|
||||||
|
&reverse_layout,
|
||||||
|
),
|
||||||
meta,
|
meta,
|
||||||
&[Some(&leveled_content)],
|
&[Some(&leveled_content)],
|
||||||
);
|
);
|
||||||
@@ -1157,7 +1165,14 @@ mod tests {
|
|||||||
field: None,
|
field: None,
|
||||||
};
|
};
|
||||||
install(
|
install(
|
||||||
RepeatNode::new(RecordSource::new(content, &content_layout, &content_layout), count_edge, reverse_edge, &content_layout, count_layout, reverse_layout),
|
RepeatNode::new(
|
||||||
|
RecordSource::new(content, &content_layout, &content_layout),
|
||||||
|
count_edge,
|
||||||
|
reverse_edge,
|
||||||
|
&content_layout,
|
||||||
|
count_layout,
|
||||||
|
reverse_layout,
|
||||||
|
),
|
||||||
meta(),
|
meta(),
|
||||||
&[Some(&content_layout)],
|
&[Some(&content_layout)],
|
||||||
)
|
)
|
||||||
@@ -1536,7 +1551,14 @@ mod tests {
|
|||||||
folded: None,
|
folded: None,
|
||||||
};
|
};
|
||||||
let nested = install(
|
let nested = install(
|
||||||
RepeatNode::new(RecordSource::new(content, &leveled_content, &leveled_content), count_edge, reverse_edge, &leveled_content, &count_layout, &reverse_layout),
|
RepeatNode::new(
|
||||||
|
RecordSource::new(content, &leveled_content, &leveled_content),
|
||||||
|
count_edge,
|
||||||
|
reverse_edge,
|
||||||
|
&leveled_content,
|
||||||
|
&count_layout,
|
||||||
|
&reverse_layout,
|
||||||
|
),
|
||||||
meta,
|
meta,
|
||||||
&[Some(&leveled_content)],
|
&[Some(&leveled_content)],
|
||||||
);
|
);
|
||||||
@@ -1578,7 +1600,14 @@ mod tests {
|
|||||||
folded: None,
|
folded: None,
|
||||||
};
|
};
|
||||||
let nested = install(
|
let nested = install(
|
||||||
RepeatNode::new(RecordSource::new(content, &leveled_content, &leveled_content), count_edge, reverse_edge, &leveled_content, &count_layout, &reverse_layout),
|
RepeatNode::new(
|
||||||
|
RecordSource::new(content, &leveled_content, &leveled_content),
|
||||||
|
count_edge,
|
||||||
|
reverse_edge,
|
||||||
|
&leveled_content,
|
||||||
|
&count_layout,
|
||||||
|
&reverse_layout,
|
||||||
|
),
|
||||||
meta,
|
meta,
|
||||||
&[Some(&leveled_content)],
|
&[Some(&leveled_content)],
|
||||||
);
|
);
|
||||||
@@ -1807,7 +1836,14 @@ mod tests {
|
|||||||
folded: None,
|
folded: None,
|
||||||
};
|
};
|
||||||
let repeat = install(
|
let repeat = install(
|
||||||
RepeatNode::new(RecordSource::new(IndexSourceNode { layout: base.clone() }, &base, &base), count_edge, reverse_edge, &base, &count_layout, &reverse_layout),
|
RepeatNode::new(
|
||||||
|
RecordSource::new(IndexSourceNode { layout: base.clone() }, &base, &base),
|
||||||
|
count_edge,
|
||||||
|
reverse_edge,
|
||||||
|
&base,
|
||||||
|
&count_layout,
|
||||||
|
&reverse_layout,
|
||||||
|
),
|
||||||
meta,
|
meta,
|
||||||
&[Some(&base)],
|
&[Some(&base)],
|
||||||
);
|
);
|
||||||
@@ -1850,7 +1886,11 @@ mod tests {
|
|||||||
|
|
||||||
let chain = install(
|
let chain = install(
|
||||||
MultiplyOpacityNode::new(
|
MultiplyOpacityNode::new(
|
||||||
install(MultiplyOpacityNode::new(bare_source(&source_layout, 2.), ValueNode(0.5), &source_layout), multiply_opacity_layout_meta(), &[Some(&source_layout)]),
|
install(
|
||||||
|
MultiplyOpacityNode::new(bare_source(&source_layout, 2.), ValueNode(0.5), &source_layout),
|
||||||
|
multiply_opacity_layout_meta(),
|
||||||
|
&[Some(&source_layout)],
|
||||||
|
),
|
||||||
ValueNode(0.5),
|
ValueNode(0.5),
|
||||||
&modified,
|
&modified,
|
||||||
),
|
),
|
||||||
@@ -1900,7 +1940,11 @@ mod tests {
|
|||||||
|
|
||||||
let chain = install(
|
let chain = install(
|
||||||
MeasureNode::new(
|
MeasureNode::new(
|
||||||
install(MultiplyOpacityNode::new(bare_source(&source_layout, -2.), ValueNode(0.5), &source_layout), multiply_opacity_layout_meta(), &[Some(&source_layout)]),
|
install(
|
||||||
|
MultiplyOpacityNode::new(bare_source(&source_layout, -2.), ValueNode(0.5), &source_layout),
|
||||||
|
multiply_opacity_layout_meta(),
|
||||||
|
&[Some(&source_layout)],
|
||||||
|
),
|
||||||
&modified,
|
&modified,
|
||||||
),
|
),
|
||||||
measure_layout_meta(),
|
measure_layout_meta(),
|
||||||
@@ -1934,7 +1978,11 @@ mod tests {
|
|||||||
|
|
||||||
let chain = install(
|
let chain = install(
|
||||||
ShadeNode::new(
|
ShadeNode::new(
|
||||||
install(MultiplyOpacityNode::new(bare_source(&source_layout, 4.), ValueNode(0.5), &source_layout), multiply_opacity_layout_meta(), &[Some(&source_layout)]),
|
install(
|
||||||
|
MultiplyOpacityNode::new(bare_source(&source_layout, 4.), ValueNode(0.5), &source_layout),
|
||||||
|
multiply_opacity_layout_meta(),
|
||||||
|
&[Some(&source_layout)],
|
||||||
|
),
|
||||||
&modified,
|
&modified,
|
||||||
),
|
),
|
||||||
shade_layout_meta(),
|
shade_layout_meta(),
|
||||||
@@ -2053,13 +2101,21 @@ mod tests {
|
|||||||
let modified = checked_multiply_opacity_layout(&source_layout);
|
let modified = checked_multiply_opacity_layout(&source_layout);
|
||||||
reserve_for(&[&source_layout, &modified]);
|
reserve_for(&[&source_layout, &modified]);
|
||||||
|
|
||||||
let ok = install(CheckedMultiplyOpacityNode::new(bare_source(&source_layout, 1.), ValueNode(0.5), &source_layout), checked_multiply_opacity_layout_meta(), &[Some(&source_layout)]);
|
let ok = install(
|
||||||
|
CheckedMultiplyOpacityNode::new(bare_source(&source_layout, 1.), ValueNode(0.5), &source_layout),
|
||||||
|
checked_multiply_opacity_layout_meta(),
|
||||||
|
&[Some(&source_layout)],
|
||||||
|
);
|
||||||
let GPoll::Final(value) = ok.eval(&ctx) else {
|
let GPoll::Final(value) = ok.eval(&ctx) else {
|
||||||
panic!("expected a final record");
|
panic!("expected a final record");
|
||||||
};
|
};
|
||||||
assert_eq!(unsafe { modified.rec(&value).read::<f64>(modified.offset_of(Opacity::NAME, 0).unwrap()) }, 0.5);
|
assert_eq!(unsafe { modified.rec(&value).read::<f64>(modified.offset_of(Opacity::NAME, 0).unwrap()) }, 0.5);
|
||||||
|
|
||||||
let failing = install(CheckedMultiplyOpacityNode::new(bare_source(&source_layout, 1.), ValueNode(-1.), &source_layout), checked_multiply_opacity_layout_meta(), &[Some(&source_layout)]);
|
let failing = install(
|
||||||
|
CheckedMultiplyOpacityNode::new(bare_source(&source_layout, 1.), ValueNode(-1.), &source_layout),
|
||||||
|
checked_multiply_opacity_layout_meta(),
|
||||||
|
&[Some(&source_layout)],
|
||||||
|
);
|
||||||
let GPoll::Error(error) = failing.eval(&ctx) else {
|
let GPoll::Error(error) = failing.eval(&ctx) else {
|
||||||
panic!("expected an error");
|
panic!("expected an error");
|
||||||
};
|
};
|
||||||
@@ -2080,7 +2136,11 @@ mod tests {
|
|||||||
|
|
||||||
let chain = install(
|
let chain = install(
|
||||||
ScaleNode::new(
|
ScaleNode::new(
|
||||||
install(MultiplyOpacityNode::new(bare_source(&source_layout, 2.), ValueNode(0.5), &source_layout), multiply_opacity_layout_meta(), &[Some(&source_layout)]),
|
install(
|
||||||
|
MultiplyOpacityNode::new(bare_source(&source_layout, 2.), ValueNode(0.5), &source_layout),
|
||||||
|
multiply_opacity_layout_meta(),
|
||||||
|
&[Some(&source_layout)],
|
||||||
|
),
|
||||||
ValueNode(3.),
|
ValueNode(3.),
|
||||||
&modified,
|
&modified,
|
||||||
),
|
),
|
||||||
@@ -2139,7 +2199,11 @@ mod tests {
|
|||||||
panic!("expected a final record");
|
panic!("expected a final record");
|
||||||
};
|
};
|
||||||
let rec = transferred.rec(&value);
|
let rec = transferred.rec(&value);
|
||||||
assert_eq!(unsafe { rec.read::<f64>(transferred.offset_of(Opacity::NAME, 0).unwrap()) }, 0.5, "an absent secondary attribute reads its default");
|
assert_eq!(
|
||||||
|
unsafe { rec.read::<f64>(transferred.offset_of(Opacity::NAME, 0).unwrap()) },
|
||||||
|
0.5,
|
||||||
|
"an absent secondary attribute reads its default"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -2346,7 +2410,11 @@ mod tests {
|
|||||||
ShadeNode::new(
|
ShadeNode::new(
|
||||||
install(
|
install(
|
||||||
StripOpacityNode::new(
|
StripOpacityNode::new(
|
||||||
install(MultiplyOpacityNode::new(bare_source(&source_layout, 4.), ValueNode(0.5), &source_layout), multiply_opacity_layout_meta(), &[Some(&source_layout)]),
|
install(
|
||||||
|
MultiplyOpacityNode::new(bare_source(&source_layout, 4.), ValueNode(0.5), &source_layout),
|
||||||
|
multiply_opacity_layout_meta(),
|
||||||
|
&[Some(&source_layout)],
|
||||||
|
),
|
||||||
&modified,
|
&modified,
|
||||||
),
|
),
|
||||||
strip_opacity_layout_meta(),
|
strip_opacity_layout_meta(),
|
||||||
@@ -2409,7 +2477,11 @@ mod tests {
|
|||||||
|
|
||||||
let chain = install(
|
let chain = install(
|
||||||
LabelNode::new(
|
LabelNode::new(
|
||||||
install(LabelNode::new(bare_source(&source_layout, 1.), ValueNode(String::from("a")), &source_layout), label_layout_meta(), &[Some(&source_layout)]),
|
install(
|
||||||
|
LabelNode::new(bare_source(&source_layout, 1.), ValueNode(String::from("a")), &source_layout),
|
||||||
|
label_layout_meta(),
|
||||||
|
&[Some(&source_layout)],
|
||||||
|
),
|
||||||
ValueNode(String::from("b")),
|
ValueNode(String::from("b")),
|
||||||
&labeled,
|
&labeled,
|
||||||
),
|
),
|
||||||
@@ -2774,7 +2846,11 @@ mod tests {
|
|||||||
let labeled = label_layout(&source_layout);
|
let labeled = label_layout(&source_layout);
|
||||||
reserve_for(&[&labeled, &labeled]);
|
reserve_for(&[&labeled, &labeled]);
|
||||||
|
|
||||||
let chain = install(LabelNode::new(bare_source(&source_layout, 1.), ValueNode(String::from("a")), &source_layout), label_layout_meta(), &[Some(&source_layout)]);
|
let chain = install(
|
||||||
|
LabelNode::new(bare_source(&source_layout, 1.), ValueNode(String::from("a")), &source_layout),
|
||||||
|
label_layout_meta(),
|
||||||
|
&[Some(&source_layout)],
|
||||||
|
);
|
||||||
let memo = crate::memo::MemoizeNode::new(chain, &labeled);
|
let memo = crate::memo::MemoizeNode::new(chain, &labeled);
|
||||||
|
|
||||||
let first_arena = Arena::new(1024).unwrap();
|
let first_arena = Arena::new(1024).unwrap();
|
||||||
|
|||||||
@@ -273,15 +273,7 @@ fn mirror<'e>(
|
|||||||
)>,
|
)>,
|
||||||
Interrupt,
|
Interrupt,
|
||||||
> {
|
> {
|
||||||
mirror_lane(
|
mirror_lane(ctx.arena(), legacy_render_list_of(content), ctx.index() as usize, relative_to_bounds, offset, angle, keep_original)
|
||||||
ctx.arena(),
|
|
||||||
legacy_render_list_of(content),
|
|
||||||
ctx.index() as usize,
|
|
||||||
relative_to_bounds,
|
|
||||||
offset,
|
|
||||||
angle,
|
|
||||||
keep_original,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The kept originals double the level, counted from the subject's extent
|
/// The kept originals double the level, counted from the subject's extent
|
||||||
@@ -331,15 +323,7 @@ fn mirror_vector<'e>(
|
|||||||
)>,
|
)>,
|
||||||
Interrupt,
|
Interrupt,
|
||||||
> {
|
> {
|
||||||
mirror_lane(
|
mirror_lane(ctx.arena(), legacy_render_list_of(content), ctx.index() as usize, relative_to_bounds, offset, angle, keep_original)
|
||||||
ctx.arena(),
|
|
||||||
legacy_render_list_of(content),
|
|
||||||
ctx.index() as usize,
|
|
||||||
relative_to_bounds,
|
|
||||||
offset,
|
|
||||||
angle,
|
|
||||||
keep_original,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mirror_vector_extent(
|
fn mirror_vector_extent(
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ use core_types::transform::Footprint;
|
|||||||
#[cfg(target_family = "wasm")]
|
#[cfg(target_family = "wasm")]
|
||||||
use core_types::{ATTR_TRANSFORM, WasmNotSend};
|
use core_types::{ATTR_TRANSFORM, WasmNotSend};
|
||||||
use core_types::{Color, Ctx, ExtractIndex, InjectIndex};
|
use core_types::{Color, Ctx, ExtractIndex, InjectIndex};
|
||||||
#[cfg(target_family = "wasm")]
|
|
||||||
use graphic_types::ATTR_EDITOR_MERGED_LAYERS;
|
|
||||||
pub use graph_craft::application_io::resource::{Resource, ResourceHash};
|
pub use graph_craft::application_io::resource::{Resource, ResourceHash};
|
||||||
pub use graph_craft::application_io::*;
|
pub use graph_craft::application_io::*;
|
||||||
pub use graph_craft::document::value::RenderOutputType;
|
pub use graph_craft::document::value::RenderOutputType;
|
||||||
#[cfg(target_family = "wasm")]
|
#[cfg(target_family = "wasm")]
|
||||||
pub use graphene_canvas_utils as canvas_utils;
|
pub use graphene_canvas_utils as canvas_utils;
|
||||||
#[cfg(target_family = "wasm")]
|
#[cfg(target_family = "wasm")]
|
||||||
|
use graphic_types::ATTR_EDITOR_MERGED_LAYERS;
|
||||||
|
#[cfg(target_family = "wasm")]
|
||||||
use graphic_types::Graphic;
|
use graphic_types::Graphic;
|
||||||
#[cfg(target_family = "wasm")]
|
#[cfg(target_family = "wasm")]
|
||||||
use graphic_types::IntoGraphicList;
|
use graphic_types::IntoGraphicList;
|
||||||
|
|||||||
@@ -42,8 +42,7 @@ fn transform_extent(content: ExtentIn<'_>, _translation: ValueIn<'_, DVec2>, _ro
|
|||||||
#[node_macro::node(category(""))]
|
#[node_macro::node(category(""))]
|
||||||
fn transform_value<T: ApplyTransform + 'static>(
|
fn transform_value<T: ApplyTransform + 'static>(
|
||||||
ctx: impl Ctx + DeriveCtx + ModifyFootprint,
|
ctx: impl Ctx + DeriveCtx + ModifyFootprint,
|
||||||
#[implementations(Context -> DAffine2, Context -> DVec2)]
|
#[implementations(Context -> DAffine2, Context -> DVec2)] content: impl Node<Context<'_>, Output = T>,
|
||||||
content: impl Node<Context<'_>, Output = T>,
|
|
||||||
#[widget(ParsedWidgetOverride::Custom = "transform_translation")] translation: DVec2,
|
#[widget(ParsedWidgetOverride::Custom = "transform_translation")] translation: DVec2,
|
||||||
#[widget(ParsedWidgetOverride::Custom = "transform_rotation")] rotation: f64,
|
#[widget(ParsedWidgetOverride::Custom = "transform_rotation")] rotation: f64,
|
||||||
#[widget(ParsedWidgetOverride::Custom = "transform_scale")]
|
#[widget(ParsedWidgetOverride::Custom = "transform_scale")]
|
||||||
@@ -68,13 +67,7 @@ pub use _transform_value_mod::transform_value_entries;
|
|||||||
/// Resets the desired components of the input transform to their default values. If all components are reset, the output will be set to the identity transform.
|
/// Resets the desired components of the input transform to their default values. If all components are reset, the output will be set to the identity transform.
|
||||||
/// Shear is represented jointly by rotation and scale, so resetting both will also remove any shear.
|
/// Shear is represented jointly by rotation and scale, so resetting both will also remove any shear.
|
||||||
#[node_macro::node(category("Math: Transform"))]
|
#[node_macro::node(category("Math: Transform"))]
|
||||||
fn reset_transform<T>(
|
fn reset_transform<T>(_: impl Ctx, (element, transform): (T, Attr<TransformAttr>), #[default(true)] reset_translation: bool, reset_rotation: bool, reset_scale: bool) -> (T, Attr<TransformAttr>) {
|
||||||
_: impl Ctx,
|
|
||||||
(element, transform): (T, Attr<TransformAttr>),
|
|
||||||
#[default(true)] reset_translation: bool,
|
|
||||||
reset_rotation: bool,
|
|
||||||
reset_scale: bool,
|
|
||||||
) -> (T, Attr<TransformAttr>) {
|
|
||||||
let mut row_transform = *transform;
|
let mut row_transform = *transform;
|
||||||
if reset_translation {
|
if reset_translation {
|
||||||
row_transform.translation = DVec2::ZERO;
|
row_transform.translation = DVec2::ZERO;
|
||||||
|
|||||||
Reference in New Issue
Block a user