Drop the stranded ranked wrappers from the node signatures

This commit is contained in:
Dennis Kobert
2026-09-08 15:16:13 +00:00
parent c98570fd8a
commit 95ce26e36c
8 changed files with 354 additions and 376 deletions

View File

@@ -36,20 +36,17 @@ fn real_time(
/// The time and date component to be produced as a number.
component: RealTimeMode,
) -> f64 {
let component = component.into_element();
let real_time = ctx.try_real_time().unwrap_or_default();
// TODO: Implement proper conversion using and existing time implementation
let result = match component {
match component {
RealTimeMode::Utc => real_time,
RealTimeMode::Year => (real_time / DAY / 365.25).floor() + 1970., // TODO: Factor in a chosen timezone
RealTimeMode::Hour => (real_time / 1000. / 3600.).floor() % 24., // TODO: Factor in a chosen timezone
RealTimeMode::Minute => (real_time / 1000. / 60.).floor() % 60., // TODO: Factor in a chosen timezone
RealTimeMode::Second => (real_time / 1000.).floor() % 60.,
RealTimeMode::Millisecond => real_time % 1000.,
};
Item::new_from_element(result)
}
}
/// Produces the time, in seconds on the timeline, since the beginning of animation playback.
@@ -61,7 +58,7 @@ fn animation_time(
#[unit("/sec")]
rate: f64,
) -> f64 {
Item::new_from_element(ctx.try_animation_time().unwrap_or_default() * *rate.element())
ctx.try_animation_time().unwrap_or_default() * rate
}
#[node_macro::node(category("Debug"))]
@@ -94,6 +91,7 @@ fn quantize_real_time<T>(
Context -> List<Color>,
Context -> List<Gradient>,
Context -> List<Artboard>,
Context -> (),
)]
value: impl Node<Context<'_>, Output = T>,
#[default(1)]
@@ -102,7 +100,6 @@ fn quantize_real_time<T>(
) -> GPoll<T> {
let time = ctx.try_real_time().unwrap_or_default();
let time = time / 1000.;
let quantum = quantum.into_element();
let mut quantized_time = (time * quantum.recip()).round() / quantum.recip();
if !quantized_time.is_finite() {
quantized_time = time;
@@ -142,6 +139,7 @@ fn quantize_animation_time<T>(
Context -> List<Color>,
Context -> List<Gradient>,
Context -> List<Artboard>,
Context -> (),
)]
value: impl Node<Context<'_>, Output = T>,
#[default(1)]
@@ -149,7 +147,6 @@ fn quantize_animation_time<T>(
quantum: f64,
) -> GPoll<T> {
let time = ctx.try_animation_time().unwrap_or_default();
let quantum = quantum.into_element();
let mut quantized_time = (time * quantum.recip()).round() / quantum.recip();
if !quantized_time.is_finite() {
quantized_time = time;
@@ -161,7 +158,7 @@ fn quantize_animation_time<T>(
/// Produces the current position of the user's pointer within the document canvas.
#[node_macro::node(category("Animation"))]
fn pointer_position(ctx: impl Ctx + ExtractPointerPosition) -> DVec2 {
Item::new_from_element(ctx.try_pointer_position().unwrap_or_default())
ctx.try_pointer_position().unwrap_or_default()
}
// TODO: These nodes require more sophisticated algorithms for giving the correct result

View File

@@ -1,5 +1,6 @@
use core_types::Ctx;
use glam::{DAffine2, DVec2};
use raster_types::{CPU, Raster};
/// Meant for debugging purposes, not general use. Logs the input value to the console and passes it through unchanged.
#[node_macro::node(category("Debug"), name("Log to Console"))]