New node: Pointer Position (#3535)

* New node: Pointer Position

* Fix test
This commit is contained in:
Keavon Chambers
2025-12-27 16:02:23 -08:00
committed by GitHub
parent 4ab75c9c1c
commit fa45efa9e2
11 changed files with 119 additions and 18 deletions

View File

@@ -1,4 +1,5 @@
use core_types::{Ctx, ExtractAnimationTime, ExtractRealTime};
use core_types::{Ctx, ExtractAnimationTime, ExtractPointer, ExtractRealTime};
use glam::DVec2;
const DAY: f64 = 1000. * 3600. * 24.;
@@ -47,6 +48,12 @@ fn animation_time(ctx: impl Ctx + ExtractAnimationTime) -> f64 {
ctx.try_animation_time().unwrap_or_default()
}
/// Produces the current position of the user's pointer within the document canvas.
#[node_macro::node(category("Animation"))]
fn pointer_position(ctx: impl Ctx + ExtractPointer) -> DVec2 {
ctx.try_pointer().unwrap_or_default()
}
// TODO: These nodes require more sophisticated algorithms for giving the correct result
// #[node_macro::node(category("Animation"))]
// fn month(ctx: impl Ctx + ExtractRealTime) -> f64 {