Add tooltip documentation to the graphic flattening nodes and string nodes (#3269)
This commit is contained in:
parent
55a64064b0
commit
3364059e02
|
|
@ -354,6 +354,7 @@ async fn to_graphic<T: Into<Table<Graphic>> + 'n>(
|
||||||
content.into()
|
content.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Removes a level of nesting from a graphic table, or all nesting if "Fully Flatten" is enabled.
|
||||||
#[node_macro::node(category("General"))]
|
#[node_macro::node(category("General"))]
|
||||||
async fn flatten_graphic(_: impl Ctx, content: Table<Graphic>, fully_flatten: bool) -> Table<Graphic> {
|
async fn flatten_graphic(_: impl Ctx, content: Table<Graphic>, fully_flatten: bool) -> Table<Graphic> {
|
||||||
// TODO: Avoid mutable reference, instead return a new Table<Graphic>?
|
// TODO: Avoid mutable reference, instead return a new Table<Graphic>?
|
||||||
|
|
@ -393,6 +394,7 @@ async fn flatten_graphic(_: impl Ctx, content: Table<Graphic>, fully_flatten: bo
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Converts a graphic table into a vector table by deeply flattening any vector content it contains, and discarding any non-vector content.
|
||||||
#[node_macro::node(category("Vector"))]
|
#[node_macro::node(category("Vector"))]
|
||||||
async fn flatten_vector(_: impl Ctx, content: Table<Graphic>) -> Table<Vector> {
|
async fn flatten_vector(_: impl Ctx, content: Table<Graphic>) -> Table<Vector> {
|
||||||
// TODO: Avoid mutable reference, instead return a new Table<Graphic>?
|
// TODO: Avoid mutable reference, instead return a new Table<Graphic>?
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,13 @@ use crate::vector::Vector;
|
||||||
use crate::{Context, Ctx};
|
use crate::{Context, Ctx};
|
||||||
use glam::{DAffine2, DVec2};
|
use glam::{DAffine2, DVec2};
|
||||||
|
|
||||||
|
/// Type-asserts a value to be a string, so the automatic type conversion system can convert another type to a string.
|
||||||
#[node_macro::node(category("Debug"))]
|
#[node_macro::node(category("Debug"))]
|
||||||
fn to_string(_: impl Ctx, value: String) -> String {
|
fn to_string(_: impl Ctx, value: String) -> String {
|
||||||
value
|
value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Converts a value to a JSON string representation.
|
||||||
#[node_macro::node(category("Text"))]
|
#[node_macro::node(category("Text"))]
|
||||||
fn serialize<T: serde::Serialize>(
|
fn serialize<T: serde::Serialize>(
|
||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
|
|
@ -22,16 +24,21 @@ fn serialize<T: serde::Serialize>(
|
||||||
serde_json::to_string(&value).unwrap_or_else(|_| "Serialization Error".to_string())
|
serde_json::to_string(&value).unwrap_or_else(|_| "Serialization Error".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Joins two strings together.
|
||||||
#[node_macro::node(category("Text"))]
|
#[node_macro::node(category("Text"))]
|
||||||
fn string_concatenate(_: impl Ctx, #[implementations(String)] first: String, second: TextArea) -> String {
|
fn string_concatenate(_: impl Ctx, #[implementations(String)] first: String, second: TextArea) -> String {
|
||||||
first.clone() + &second
|
first.clone() + &second
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Replaces all occurrences of "From" with "To" in the input string.
|
||||||
#[node_macro::node(category("Text"))]
|
#[node_macro::node(category("Text"))]
|
||||||
fn string_replace(_: impl Ctx, string: String, from: TextArea, to: TextArea) -> String {
|
fn string_replace(_: impl Ctx, string: String, from: TextArea, to: TextArea) -> String {
|
||||||
string.replace(&from, &to)
|
string.replace(&from, &to)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Extracts a substring from the input string, starting at "Start" and ending before "End".
|
||||||
|
/// Negative indices count from the end of the string.
|
||||||
|
/// If "Start" equals or exceeds "End", the result is an empty string.
|
||||||
#[node_macro::node(category("Text"))]
|
#[node_macro::node(category("Text"))]
|
||||||
fn string_slice(_: impl Ctx, string: String, start: f64, end: f64) -> String {
|
fn string_slice(_: impl Ctx, string: String, start: f64, end: f64) -> String {
|
||||||
let total_chars = string.chars().count();
|
let total_chars = string.chars().count();
|
||||||
|
|
@ -56,11 +63,13 @@ fn string_slice(_: impl Ctx, string: String, start: f64, end: f64) -> String {
|
||||||
|
|
||||||
// TODO: Return u32, u64, or usize instead of f64 after #1621 is resolved and has allowed us to implement automatic type conversion in the node graph for nodes with generic type inputs.
|
// TODO: Return u32, u64, or usize instead of f64 after #1621 is resolved and has allowed us to implement automatic type conversion in the node graph for nodes with generic type inputs.
|
||||||
// TODO: (Currently automatic type conversion only works for concrete types, via the Graphene preprocessor and not the full Graphene type system.)
|
// TODO: (Currently automatic type conversion only works for concrete types, via the Graphene preprocessor and not the full Graphene type system.)
|
||||||
|
/// Counts the number of characters in a string.
|
||||||
#[node_macro::node(category("Text"))]
|
#[node_macro::node(category("Text"))]
|
||||||
fn string_length(_: impl Ctx, string: String) -> f64 {
|
fn string_length(_: impl Ctx, string: String) -> f64 {
|
||||||
string.chars().count() as f64
|
string.chars().count() as f64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Evaluates either the "If True" or "If False" input branch based on whether the input condition is true or false.
|
||||||
#[node_macro::node(category("Math: Logic"))]
|
#[node_macro::node(category("Math: Logic"))]
|
||||||
async fn switch<T, C: Send + 'n + Clone>(
|
async fn switch<T, C: Send + 'n + Clone>(
|
||||||
#[implementations(Context)] ctx: C,
|
#[implementations(Context)] ctx: C,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue