Files
armorpaint/paint/sources/nodes/tex_image_node.ts
T

104 lines
1.9 KiB
TypeScript
Raw Normal View History

2024-03-14 23:58:24 +01:00
type tex_image_node_t = {
base?: logic_node_t;
2024-09-24 16:50:54 +02:00
raw?: ui_node_t;
2024-03-14 23:58:24 +01:00
};
2024-09-24 16:50:54 +02:00
function tex_image_node_create(raw: ui_node_t, args: f32_array_t): tex_image_node_t {
2024-03-14 23:58:24 +01:00
let n: tex_image_node_t = {};
2024-10-21 19:28:43 +02:00
n.base = logic_node_create(n);
2024-03-14 23:58:24 +01:00
n.base.get = tex_image_node_get;
2024-09-24 16:50:54 +02:00
n.raw = raw;
2024-03-14 23:58:24 +01:00
return n;
}
2024-04-08 17:40:32 +02:00
function tex_image_node_get(self: tex_image_node_t, from: i32): logic_node_value_t {
2024-09-24 16:50:54 +02:00
let ar: string[] = ui_nodes_enum_texts(self.raw.type);
let i: i32 = self.raw.buttons[0].default_value[0];
2024-10-21 19:28:43 +02:00
let file: string = ar[i];
2024-09-24 16:06:49 +02:00
2024-03-20 16:13:54 +01:00
if (from == 0) {
2024-09-24 16:06:49 +02:00
let v: logic_node_value_t = { _str: file + ".rgb" };
2024-04-08 17:40:32 +02:00
return v;
2024-03-20 16:13:54 +01:00
}
else {
2024-09-24 16:06:49 +02:00
let v: logic_node_value_t = { _str: file + ".a" };
2024-04-08 17:40:32 +02:00
return v;
2024-03-20 16:13:54 +01:00
}
2024-03-14 23:58:24 +01:00
}
2024-09-03 15:52:05 +02:00
let tex_image_node_def: ui_node_t = {
2024-03-14 23:58:24 +01:00
id: 0,
name: _tr("Image Texture"),
2024-09-24 16:06:49 +02:00
// type: "tex_image_node",
type: "TEX_IMAGE",
2024-03-14 23:58:24 +01:00
x: 0,
y: 0,
color: 0xff4982a0,
inputs: [
{
id: 0,
node_id: 0,
name: _tr("Vector"),
type: "VECTOR",
color: 0xff6363c7,
2024-04-10 19:39:17 +02:00
default_value: f32_array_create_xyz(0.0, 0.0, 0.0),
min: 0.0,
max: 1.0,
precision: 100,
display: 0
2024-03-14 23:58:24 +01:00
}
],
outputs: [
{
id: 0,
node_id: 0,
name: _tr("Color"),
type: "VALUE", // Match brush output socket type
color: 0xffc7c729,
2024-04-10 19:39:17 +02:00
default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0),
min: 0.0,
max: 1.0,
precision: 100,
display: 0
2024-03-14 23:58:24 +01:00
},
{
id: 0,
node_id: 0,
name: _tr("Alpha"),
type: "VALUE",
color: 0xffa1a1a1,
2024-04-24 12:14:47 +02:00
default_value: f32_array_create_x(1.0),
2024-04-10 19:39:17 +02:00
min: 0.0,
max: 1.0,
precision: 100,
display: 0
2024-03-14 23:58:24 +01:00
}
],
buttons: [
{
name: _tr("file"),
type: "ENUM",
2024-04-10 19:39:17 +02:00
output: -1,
2024-04-24 12:14:47 +02:00
default_value: f32_array_create_x(0),
data: u8_array_create_from_string(""),
2024-04-10 19:39:17 +02:00
min: 0.0,
max: 1.0,
precision: 100,
height: 0
2024-03-14 23:58:24 +01:00
},
{
name: _tr("color_space"),
type: "ENUM",
2024-04-10 19:39:17 +02:00
output: -1,
2024-04-24 12:14:47 +02:00
default_value: f32_array_create_x(0),
2024-08-31 17:24:01 +02:00
data: u8_array_create_from_string("linear\nsrgb"),
2024-04-10 19:39:17 +02:00
min: 0.0,
max: 1.0,
precision: 100,
height: 0
2024-03-14 23:58:24 +01:00
}
2024-04-10 19:39:17 +02:00
],
width: 0
2024-03-14 23:58:24 +01:00
};