mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 05:18:19 +00:00
Improve older document upgrading compatibility and make node type errors clearer (#2201)
* Improve older document upgrading compatibility and make node type errors clearer Misc. * Fixes * Avoid unwrap
This commit is contained in:
parent
eec0ef761c
commit
8505ed3f10
13 changed files with 154 additions and 74 deletions
|
@ -20,7 +20,7 @@ pub mod types {
|
|||
pub type PixelLength = f64;
|
||||
/// Non negative
|
||||
pub type Length = f64;
|
||||
/// 0.- 1.
|
||||
/// 0 to 1
|
||||
pub type Fraction = f64;
|
||||
pub type IntegerCount = u32;
|
||||
/// Int input with randomization button
|
||||
|
|
|
@ -110,7 +110,7 @@ impl NodeIOTypes {
|
|||
impl core::fmt::Debug for NodeIOTypes {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
f.write_fmt(format_args!(
|
||||
"node({}) -> {}",
|
||||
"node({}) → {}",
|
||||
[&self.call_argument].into_iter().chain(&self.inputs).map(|input| input.to_string()).collect::<Vec<_>>().join(", "),
|
||||
self.return_value
|
||||
))
|
||||
|
@ -292,13 +292,13 @@ fn format_type(ty: &str) -> String {
|
|||
impl core::fmt::Debug for Type {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
match self {
|
||||
Self::Generic(arg0) => write!(f, "Generic({arg0})"),
|
||||
Self::Generic(arg0) => write!(f, "Generic<{arg0}>"),
|
||||
#[cfg(feature = "type_id_logging")]
|
||||
Self::Concrete(arg0) => write!(f, "Concrete({}, {:?})", arg0.name, arg0.id),
|
||||
Self::Concrete(arg0) => write!(f, "Concrete<{}, {:?}>", arg0.name, arg0.id),
|
||||
#[cfg(not(feature = "type_id_logging"))]
|
||||
Self::Concrete(arg0) => write!(f, "Concrete({})", format_type(&arg0.name)),
|
||||
Self::Fn(arg0, arg1) => write!(f, "({arg0:?} -> {arg1:?})"),
|
||||
Self::Future(arg0) => write!(f, "Future({arg0:?})"),
|
||||
Self::Concrete(arg0) => write!(f, "Concrete<{}>", format_type(&arg0.name)),
|
||||
Self::Fn(arg0, arg1) => write!(f, "{arg0:?} → {arg1:?}"),
|
||||
Self::Future(arg0) => write!(f, "Future<{arg0:?}>"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ impl std::fmt::Display for Type {
|
|||
match self {
|
||||
Type::Generic(name) => write!(f, "{name}"),
|
||||
Type::Concrete(ty) => write!(f, "{}", format_type(&ty.name)),
|
||||
Type::Fn(input, output) => write!(f, "({input} -> {output})"),
|
||||
Type::Fn(input, output) => write!(f, "{input} → {output}"),
|
||||
Type::Future(ty) => write!(f, "Future<{ty}>"),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -588,7 +588,7 @@ impl ConcatElement for GraphicGroup {
|
|||
}
|
||||
}
|
||||
|
||||
#[node_macro::node(category(""))]
|
||||
#[node_macro::node(category(""), path(graphene_core::vector))]
|
||||
async fn sample_points<F: 'n + Send + Copy>(
|
||||
#[implementations(
|
||||
(),
|
||||
|
@ -815,7 +815,7 @@ async fn poisson_disk_points<F: 'n + Send>(
|
|||
result
|
||||
}
|
||||
|
||||
#[node_macro::node(category(""))]
|
||||
#[node_macro::node(category(""), path(graphene_core::vector))]
|
||||
async fn subpath_segment_lengths<F: 'n + Send>(
|
||||
#[implementations(
|
||||
(),
|
||||
|
@ -979,6 +979,8 @@ async fn morph<F: 'n + Send + Copy>(
|
|||
let target = target.eval(footprint).await;
|
||||
let mut result = VectorData::empty();
|
||||
|
||||
let time = time.clamp(0., 1.);
|
||||
|
||||
// Lerp styles
|
||||
result.alpha_blending = if time < 0.5 { source.alpha_blending } else { target.alpha_blending };
|
||||
result.style = source.style.lerp(&target.style, time);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue