Mostly working instancing + box packing

This commit is contained in:
Oliver Davies
2025-04-18 14:47:19 -07:00
committed by Keavon Chambers
parent c9192307c7
commit fa3e6eeca9
5 changed files with 172 additions and 16 deletions

View File

@@ -33,6 +33,22 @@ fn string_slice(_: impl Ctx, #[implementations(String)] string: String, start: f
string.char_indices().skip(start).take(n).map(|(_, c)| c).collect()
}
#[node_macro::node(category("Text"))]
fn split_string_by_index(
_: impl Ctx,
#[implementations(String)]
/// The comma-separated string to split.
input: String,
/// The zero-based index of the item to retrieve.
#[default(0.0)]
#[min(0.0)]
index: f64,
) -> String {
let parts: Vec<&str> = input.split(',').map(|s| s.trim()).collect();
let floored_index = index.floor() as usize;
if floored_index < parts.len() { parts[floored_index].to_string() } else { String::new() }
}
#[node_macro::node(category("Text"))]
fn string_length(_: impl Ctx, #[implementations(String)] string: String) -> usize {
string.len()