Files
armorpaint/paint/sources/nodes_brush/time_node.c
T

80 lines
4.5 KiB
C
Raw Normal View History

2026-03-06 12:56:38 +01:00
2026-03-09 13:17:15 +01:00
#include "../global.h"
2026-06-05 14:48:27 +02:00
typedef struct time_node {
struct logic_node *base;
} time_node_t;
2026-03-06 12:56:38 +01:00
logic_node_value_t *time_node_get(time_node_t *self, i32 from) {
if (from == 0) {
logic_node_value_t *v = GC_ALLOC_INIT(logic_node_value_t, {._f32 = sys_time()});
return v;
}
else if (from == 1) {
logic_node_value_t *v = GC_ALLOC_INIT(logic_node_value_t, {._f32 = sys_delta()});
return v;
}
else {
2026-04-05 16:41:00 +02:00
logic_node_value_t *v = GC_ALLOC_INIT(logic_node_value_t, {._f32 = g_context->brush_time});
2026-03-06 12:56:38 +01:00
return v;
}
}
2026-04-04 21:38:20 +02:00
2026-06-05 14:48:27 +02:00
void *time_node_create(ui_node_t *raw, f32_array_t *args) {
2026-04-04 21:38:20 +02:00
time_node_t *n = GC_ALLOC_INIT(time_node_t, {0});
n->base = logic_node_create(n);
n->base->get = time_node_get;
return n;
}
2026-07-16 11:40:26 +02:00
void time_node_init() {
ui_node_t *time_node_def =
GC_ALLOC_INIT(ui_node_t, {.id = 0,
.name = _tr("Time"),
.type = "time_node",
.x = 0,
.y = 0,
.color = 0xff4982a0,
.inputs = any_array_create_from_raw((void *[]){}, 0),
.outputs = any_array_create_from_raw(
(void *[]){
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
.node_id = 0,
.name = _tr("Time"),
.type = "VALUE",
.color = 0xffa1a1a1,
.default_value = f32_array_create_x(0.0),
.min = 0.0,
.max = 1.0,
.precision = 100,
.display = 0}),
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
.node_id = 0,
.name = _tr("Delta"),
.type = "VALUE",
.color = 0xffa1a1a1,
.default_value = f32_array_create_x(0.0),
.min = 0.0,
.max = 1.0,
.precision = 100,
.display = 0}),
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
.node_id = 0,
.name = _tr("Brush"),
.type = "VALUE",
.color = 0xffa1a1a1,
.default_value = f32_array_create_x(0.0),
.min = 0.0,
.max = 1.0,
.precision = 100,
.display = 0}),
},
3),
.buttons = any_array_create_from_raw((void *[]){}, 0),
.width = 0,
.flags = 0});
any_array_push(nodes_brush_category0, time_node_def);
any_map_set(nodes_brush_creates, "time_node", time_node_create);
}