mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-23 21:46:17 +01:00
surface buffer
This commit is contained in:
parent
1a8082e2b6
commit
979c9b28a0
33 changed files with 362 additions and 50 deletions
|
@ -161,6 +161,8 @@
|
|||
{"name":"gameframe","order":2,"path":"folders/sprites/gameframe.yy",},
|
||||
{"name":"misc","order":3,"path":"folders/sprites/misc.yy",},
|
||||
{"name":"widgets","order":5,"path":"folders/widgets.yy",},
|
||||
{"name":"surface","order":53,"path":"folders/nodes/icons/value/surface.yy",},
|
||||
{"name":"buffer","order":11,"path":"folders/nodes/data/value/buffer.yy",},
|
||||
],
|
||||
"ResourceOrderSettings": [
|
||||
{"name":"s_node_corner","order":16,"path":"sprites/s_node_corner/s_node_corner.yy",},
|
||||
|
@ -176,7 +178,6 @@
|
|||
{"name":"surface_functions","order":5,"path":"scripts/surface_functions/surface_functions.yy",},
|
||||
{"name":"sh_fd_add_velocity_glsl","order":1,"path":"shaders/sh_fd_add_velocity_glsl/sh_fd_add_velocity_glsl.yy",},
|
||||
{"name":"s_node_normal","order":30,"path":"sprites/s_node_normal/s_node_normal.yy",},
|
||||
{"name":"buffer_function","order":3,"path":"scripts/buffer_function/buffer_function.yy",},
|
||||
{"name":"node_pixel_sort","order":12,"path":"scripts/node_pixel_sort/node_pixel_sort.yy",},
|
||||
{"name":"sh_dither","order":28,"path":"shaders/sh_dither/sh_dither.yy",},
|
||||
{"name":"s_node_text_file_read","order":13,"path":"sprites/s_node_text_file_read/s_node_text_file_read.yy",},
|
||||
|
@ -519,6 +520,7 @@
|
|||
{"name":"node_unicode","order":1,"path":"scripts/node_unicode/node_unicode.yy",},
|
||||
{"name":"draw_set_text","order":1,"path":"scripts/draw_set_text/draw_set_text.yy",},
|
||||
{"name":"s_node_warp","order":9,"path":"sprites/s_node_warp/s_node_warp.yy",},
|
||||
{"name":"s_node_surface_from_buffer","order":1,"path":"sprites/s_node_surface_from_buffer/s_node_surface_from_buffer.yy",},
|
||||
{"name":"node_iterator_filter_output","order":2,"path":"scripts/node_iterator_filter_output/node_iterator_filter_output.yy",},
|
||||
{"name":"color_function","order":9,"path":"scripts/color_function/color_function.yy",},
|
||||
{"name":"fd_rectangle_set_pressure_size","order":11,"path":"scripts/fd_rectangle_set_pressure_size/fd_rectangle_set_pressure_size.yy",},
|
||||
|
@ -593,6 +595,7 @@
|
|||
{"name":"node_palette","order":4,"path":"scripts/node_palette/node_palette.yy",},
|
||||
{"name":"buttonColor","order":3,"path":"scripts/buttonColor/buttonColor.yy",},
|
||||
{"name":"notification_system","order":7,"path":"scripts/notification_system/notification_system.yy",},
|
||||
{"name":"buffer_object","order":1,"path":"scripts/buffer_object/buffer_object.yy",},
|
||||
{"name":"s_node_audio_trim","order":3,"path":"sprites/s_node_audio_trim/s_node_audio_trim.yy",},
|
||||
{"name":"node_color_from_hsv","order":8,"path":"scripts/node_color_from_hsv/node_color_from_hsv.yy",},
|
||||
{"name":"s_node_image_copy","order":3,"path":"sprites/s_node_image_copy/s_node_image_copy.yy",},
|
||||
|
@ -1039,6 +1042,7 @@
|
|||
{"name":"s_node_rigidSim_deactivate","order":7,"path":"sprites/s_node_rigidSim_deactivate/s_node_rigidSim_deactivate.yy",},
|
||||
{"name":"sh_blend_contrast","order":16,"path":"shaders/sh_blend_contrast/sh_blend_contrast.yy",},
|
||||
{"name":"node_3d_prim_cube","order":1,"path":"scripts/node_3d_prim_cube/node_3d_prim_cube.yy",},
|
||||
{"name":"node_surface_from_buffer","order":3,"path":"scripts/node_surface_from_buffer/node_surface_from_buffer.yy",},
|
||||
{"name":"s_node_fluidSim_add_collider","order":1,"path":"sprites/s_node_fluidSim_add_collider/s_node_fluidSim_add_collider.yy",},
|
||||
{"name":"node_3d_plane","order":4,"path":"scripts/node_3d_plane/node_3d_plane.yy",},
|
||||
{"name":"node_display_text","order":3,"path":"scripts/node_display_text/node_display_text.yy",},
|
||||
|
|
|
@ -197,6 +197,8 @@
|
|||
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"Steamworks","folderPath":"folders/Steamworks.yy",},
|
||||
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"UGC","folderPath":"folders/Steamworks/UGC.yy",},
|
||||
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"widgets","folderPath":"folders/widgets.yy",},
|
||||
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"surface","folderPath":"folders/nodes/icons/value/surface.yy",},
|
||||
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"buffer","folderPath":"folders/nodes/data/value/buffer.yy",},
|
||||
],
|
||||
"IncludedFiles": [
|
||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ApolloHelp.html","ConfigValues":{"Itch":{"CopyToMask":"0",},},"CopyToMask":-1,"filePath":"datafiles",},
|
||||
|
@ -633,7 +635,6 @@
|
|||
{"id":{"name":"surface_functions","path":"scripts/surface_functions/surface_functions.yy",},},
|
||||
{"id":{"name":"sh_fd_add_velocity_glsl","path":"shaders/sh_fd_add_velocity_glsl/sh_fd_add_velocity_glsl.yy",},},
|
||||
{"id":{"name":"s_node_normal","path":"sprites/s_node_normal/s_node_normal.yy",},},
|
||||
{"id":{"name":"buffer_function","path":"scripts/buffer_function/buffer_function.yy",},},
|
||||
{"id":{"name":"node_pixel_sort","path":"scripts/node_pixel_sort/node_pixel_sort.yy",},},
|
||||
{"id":{"name":"sh_dither","path":"shaders/sh_dither/sh_dither.yy",},},
|
||||
{"id":{"name":"control_function","path":"scripts/control_function/control_function.yy",},},
|
||||
|
@ -992,6 +993,7 @@
|
|||
{"id":{"name":"node_find_pixel","path":"scripts/node_find_pixel/node_find_pixel.yy",},},
|
||||
{"id":{"name":"node_scatter_points","path":"scripts/node_scatter_points/node_scatter_points.yy",},},
|
||||
{"id":{"name":"pack_bottom_left","path":"scripts/pack_bottom_left/pack_bottom_left.yy",},},
|
||||
{"id":{"name":"s_node_surface_to_buffer","path":"sprites/s_node_surface_to_buffer/s_node_surface_to_buffer.yy",},},
|
||||
{"id":{"name":"o_dialog_lua_reference","path":"objects/o_dialog_lua_reference/o_dialog_lua_reference.yy",},},
|
||||
{"id":{"name":"node_surface_data","path":"scripts/node_surface_data/node_surface_data.yy",},},
|
||||
{"id":{"name":"node_strand_gravity","path":"scripts/node_strand_gravity/node_strand_gravity.yy",},},
|
||||
|
@ -1032,6 +1034,7 @@
|
|||
{"id":{"name":"draw_set_text","path":"scripts/draw_set_text/draw_set_text.yy",},},
|
||||
{"id":{"name":"s_node_array","path":"sprites/s_node_array/s_node_array.yy",},},
|
||||
{"id":{"name":"s_node_warp","path":"sprites/s_node_warp/s_node_warp.yy",},},
|
||||
{"id":{"name":"s_node_surface_from_buffer","path":"sprites/s_node_surface_from_buffer/s_node_surface_from_buffer.yy",},},
|
||||
{"id":{"name":"node_iterator_filter_output","path":"scripts/node_iterator_filter_output/node_iterator_filter_output.yy",},},
|
||||
{"id":{"name":"color_function","path":"scripts/color_function/color_function.yy",},},
|
||||
{"id":{"name":"fd_rectangle_set_pressure_size","path":"scripts/fd_rectangle_set_pressure_size/fd_rectangle_set_pressure_size.yy",},},
|
||||
|
@ -1113,6 +1116,7 @@
|
|||
{"id":{"name":"node_palette","path":"scripts/node_palette/node_palette.yy",},},
|
||||
{"id":{"name":"buttonColor","path":"scripts/buttonColor/buttonColor.yy",},},
|
||||
{"id":{"name":"notification_system","path":"scripts/notification_system/notification_system.yy",},},
|
||||
{"id":{"name":"buffer_object","path":"scripts/buffer_object/buffer_object.yy",},},
|
||||
{"id":{"name":"s_node_audio_trim","path":"sprites/s_node_audio_trim/s_node_audio_trim.yy",},},
|
||||
{"id":{"name":"sh_shadow_cast","path":"shaders/sh_shadow_cast/sh_shadow_cast.yy",},},
|
||||
{"id":{"name":"node_color_from_hsv","path":"scripts/node_color_from_hsv/node_color_from_hsv.yy",},},
|
||||
|
@ -1540,6 +1544,7 @@
|
|||
{"id":{"name":"node_erode","path":"scripts/node_erode/node_erode.yy",},},
|
||||
{"id":{"name":"draw_circle_angle","path":"scripts/draw_circle_angle/draw_circle_angle.yy",},},
|
||||
{"id":{"name":"node_wrap_mesh","path":"scripts/node_wrap_mesh/node_wrap_mesh.yy",},},
|
||||
{"id":{"name":"node_surface_to_buffer","path":"scripts/node_surface_to_buffer/node_surface_to_buffer.yy",},},
|
||||
{"id":{"name":"node_curve","path":"scripts/node_curve/node_curve.yy",},},
|
||||
{"id":{"name":"sh_alpha_hash","path":"shaders/sh_alpha_hash/sh_alpha_hash.yy",},},
|
||||
{"id":{"name":"panel_node_align","path":"scripts/panel_node_align/panel_node_align.yy",},},
|
||||
|
@ -1621,6 +1626,7 @@
|
|||
{"id":{"name":"s_node_rigidSim_deactivate","path":"sprites/s_node_rigidSim_deactivate/s_node_rigidSim_deactivate.yy",},},
|
||||
{"id":{"name":"sh_blend_contrast","path":"shaders/sh_blend_contrast/sh_blend_contrast.yy",},},
|
||||
{"id":{"name":"node_3d_prim_cube","path":"scripts/node_3d_prim_cube/node_3d_prim_cube.yy",},},
|
||||
{"id":{"name":"node_surface_from_buffer","path":"scripts/node_surface_from_buffer/node_surface_from_buffer.yy",},},
|
||||
{"id":{"name":"s_node_fluidSim_add_collider","path":"sprites/s_node_fluidSim_add_collider/s_node_fluidSim_add_collider.yy",},},
|
||||
{"id":{"name":"node_3d_plane","path":"scripts/node_3d_plane/node_3d_plane.yy",},},
|
||||
{"id":{"name":"node_display_text","path":"scripts/node_display_text/node_display_text.yy",},},
|
||||
|
|
Binary file not shown.
|
@ -76,6 +76,9 @@ if(OS == os_windows && gameframe_is_minimized()) exit;
|
|||
case VALUE_TYPE.atlas :
|
||||
draw_tooltip_atlas(content);
|
||||
break;
|
||||
case VALUE_TYPE.buffer :
|
||||
draw_tooltip_buffer(content);
|
||||
break;
|
||||
}
|
||||
} else
|
||||
draw_tooltip_text(TOOLTIP);
|
||||
|
|
|
@ -9,15 +9,14 @@ function bin_fraction(intVal, len) {
|
|||
return val;
|
||||
}
|
||||
|
||||
/// GMLscripts.com
|
||||
function dec_to_hex(dec, len = 1) {
|
||||
static dig = "0123456789ABCDEF";
|
||||
var hex = "";
|
||||
|
||||
if (dec < 0) {
|
||||
len = max(len, ceil(logn(16, 2 * abs(dec))));
|
||||
}
|
||||
|
||||
var dig = "0123456789ABCDEF";
|
||||
while (len-- || dec) {
|
||||
hex = string_char_at(dig, (dec & $F) + 1) + hex;
|
||||
dec = dec >> 4;
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
function buffer_get_color(buffer, _x, _y, w, h) {
|
||||
buffer_seek(buffer, buffer_seek_start, (w * _y + _x) * 4);
|
||||
var c = buffer_read(buffer, buffer_u32);
|
||||
|
||||
return c;
|
||||
}
|
|
@ -1,11 +1,20 @@
|
|||
function buffer_get_string(buffer) {
|
||||
function buffer_get_color(buffer, _x, _y, w, h) {
|
||||
buffer_seek(buffer, buffer_seek_start, (w * _y + _x) * 4);
|
||||
var c = buffer_read(buffer, buffer_u32);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
function buffer_get_string(buffer, text = true) {
|
||||
buffer_seek(buffer, buffer_seek_start, 0);
|
||||
var len = buffer_get_size(buffer);
|
||||
var ss = "";
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
var _s = chr(buffer_read(buffer, buffer_u8));
|
||||
var _r = buffer_read(buffer, buffer_u8);
|
||||
var _s = text? chr(_r) : dec_to_hex(_r, 2);
|
||||
ss += _s;
|
||||
if(!text && i % 2) ss += " ";
|
||||
}
|
||||
|
||||
return ss;
|
||||
|
@ -18,9 +27,21 @@ function buffer_from_string(str) {
|
|||
return _b;
|
||||
}
|
||||
|
||||
function buffer_from_surface(surface) {
|
||||
var _b = buffer_create(surface_get_width(surface) * surface_get_height(surface), buffer_fast, 1);
|
||||
buffer_set_surface(_b, surface, 0);
|
||||
function buffer_from_surface(surface, size = true) {
|
||||
static header_length = 24;
|
||||
if(!is_surface(surface)) return noone;
|
||||
|
||||
var bitSize = surface_format_get_bytes(surface_get_format(surface));
|
||||
|
||||
var _b = buffer_create((header_length * size) + surface_get_width(surface) * surface_get_height(surface) * bitSize, buffer_fixed, 1);
|
||||
if(size) {
|
||||
buffer_write(_b, buffer_text, "PXCS");
|
||||
buffer_write(_b, buffer_u16, surface_get_width(surface));
|
||||
buffer_write(_b, buffer_u16, surface_get_height(surface));
|
||||
buffer_write(_b, buffer_u8, surface_get_format(surface));
|
||||
}
|
||||
|
||||
buffer_get_surface(_b, surface, header_length * size);
|
||||
return _b;
|
||||
}
|
||||
|
||||
|
|
7
scripts/buffer_object/buffer_object.gml
Normal file
7
scripts/buffer_object/buffer_object.gml
Normal file
|
@ -0,0 +1,7 @@
|
|||
function Buffer(buff) constructor {
|
||||
self.buffer = buff;
|
||||
|
||||
static destroy = function() {
|
||||
buffer_delete(buffer);
|
||||
}
|
||||
}
|
11
scripts/buffer_object/buffer_object.yy
Normal file
11
scripts/buffer_object/buffer_object.yy
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"resourceType": "GMScript",
|
||||
"resourceVersion": "1.0",
|
||||
"name": "buffer_object",
|
||||
"isCompatibility": false,
|
||||
"isDnD": false,
|
||||
"parent": {
|
||||
"name": "buffer",
|
||||
"path": "folders/functions/buffer.yy",
|
||||
},
|
||||
}
|
|
@ -160,4 +160,9 @@ function draw_tooltip_atlas(atlas) {
|
|||
draw_text_add(sx + ui(160), _y + ui(16), atl.rotation);
|
||||
draw_text_add(sx + ui(160), _y + ui(32), atl.scale);
|
||||
}
|
||||
}
|
||||
|
||||
function draw_tooltip_buffer(buff) {
|
||||
var txt = buffer_get_string(buff, false);
|
||||
draw_tooltip_text(txt);
|
||||
}
|
|
@ -31,10 +31,10 @@
|
|||
|
||||
globalvar VERSION, SAVEFILE_VERSION, VERSION_STRING, BUILD_NUMBER;
|
||||
|
||||
VERSION = 1145;
|
||||
VERSION = 1146;
|
||||
SAVEFILE_VERSION = 1440;
|
||||
VERSION_STRING = "1.14.5n2";
|
||||
BUILD_NUMBER = 114502;
|
||||
VERSION_STRING = "1.14.5n3";
|
||||
BUILD_NUMBER = 114503;
|
||||
|
||||
globalvar NODES, NODE_MAP, APPEND_MAP, NODE_NAME_MAP;
|
||||
globalvar HOTKEYS, HOTKEY_CONTEXT, NODE_INSTANCES;
|
||||
|
|
|
@ -129,11 +129,11 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
|
|||
for( var i = 0; i < array_length(_b.childs); i++ ) {
|
||||
var bone = _b.childs[i];
|
||||
|
||||
var _x = lengthdir_x(bone.distance, bone.direction) + dx;
|
||||
var _y = lengthdir_y(bone.distance, bone.direction) + dy;
|
||||
var _bx = lengthdir_x(bone.distance, bone.direction) + dx;
|
||||
var _by = lengthdir_y(bone.distance, bone.direction) + dy;
|
||||
|
||||
bone.distance = point_distance(0, 0, _x, _y);
|
||||
bone.direction = point_direction(0, 0, _x, _y);
|
||||
bone.distance = point_distance(0, 0, _bx, _by);
|
||||
bone.direction = point_direction(0, 0, _bx, _by);
|
||||
}
|
||||
|
||||
if(mouse_release(mb_left))
|
||||
|
|
|
@ -29,12 +29,15 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
|
||||
inputs[| 10] = nodeValue("Render background", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
||||
|
||||
inputs[| 11] = nodeValue("Alpha", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1 )
|
||||
.setDisplay(VALUE_DISPLAY.slider, [0, 1, 0.01]);
|
||||
|
||||
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||
outputs[| 1] = nodeValue("Preview", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||
|
||||
input_display_list = [
|
||||
["Output", false], 0,
|
||||
["Brush", false], 6, 1, 2,
|
||||
["Brush", false], 6, 2, 1, 11,
|
||||
["Fill", false], 3, 4,
|
||||
["Display", false], 5, 8, 9, 10,
|
||||
];
|
||||
|
@ -49,10 +52,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
|
||||
tool_channel_edit = new checkBoxGroup(THEME.tools_canvas_channel, function(ind, val) { tool_attribute.channel[ind] = val; });
|
||||
tool_attribute.channel = [ true, true, true, true ];
|
||||
tool_attribute.alpha = 1;
|
||||
tool_settings = [
|
||||
[ "Channel", tool_channel_edit, "channel", tool_attribute ],
|
||||
[ "Alpha", new textBox(TEXTBOX_INPUT.number, function(alp) { tool_attribute.alpha = alp; }), "alpha", tool_attribute ],
|
||||
];
|
||||
|
||||
tools = [
|
||||
|
@ -78,10 +79,12 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
}
|
||||
|
||||
function apply_draw_surface() {
|
||||
var _alp = inputs[| 11].getValue();
|
||||
|
||||
BLEND_ALPHA;
|
||||
if(isUsingTool(1))
|
||||
gpu_set_blendmode(bm_subtract);
|
||||
draw_surface_ext_safe(drawing_surface, 0, 0, 1, 1, 0, c_white, tool_attribute.alpha);
|
||||
draw_surface_ext_safe(drawing_surface, 0, 0, 1, 1, 0, c_white, _alp);
|
||||
|
||||
surface_set_target(drawing_surface);
|
||||
DRAW_CLEAR
|
||||
|
@ -279,6 +282,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
}
|
||||
|
||||
function flood_fill_scanline(_x, _y, _surf, _thres, _corner = false) {
|
||||
var _alp = inputs[| 11].getValue();
|
||||
|
||||
var colorFill = draw_get_color() + (255 << 24);
|
||||
var colorBase = get_color_buffer(_x, _y);
|
||||
|
||||
|
@ -311,7 +316,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
spanBelow = false;
|
||||
|
||||
while(x1 < surface_w && ff_fillable(colorBase, colorFill, x1, y1, thr)) {
|
||||
draw_set_alpha(tool_attribute.alpha);
|
||||
draw_set_alpha(_alp);
|
||||
draw_point(x1, y1);
|
||||
draw_set_alpha(1);
|
||||
|
||||
|
@ -367,13 +372,15 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
}
|
||||
|
||||
function canvas_fill(_x, _y, _surf, _thres) {
|
||||
var _alp = inputs[| 11].getValue();
|
||||
|
||||
var w = surface_get_width(_surf);
|
||||
var h = surface_get_height(_surf);
|
||||
|
||||
var _c1 = get_color_buffer(_x, _y);
|
||||
var thr = _thres * _thres;
|
||||
|
||||
draw_set_alpha(tool_attribute.alpha);
|
||||
draw_set_alpha(_alp);
|
||||
for( var i = 0; i < w; i++ ) {
|
||||
for( var j = 0; j < h; j++ ) {
|
||||
if(i == _x && j == _y) {
|
||||
|
@ -541,8 +548,9 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
surface_reset_target();
|
||||
|
||||
#region preview
|
||||
var _bg = inputs[| 8].getValue();
|
||||
var _bga = inputs[| 9].getValue();
|
||||
var _bg = inputs[| 8].getValue();
|
||||
var _bga = inputs[| 9].getValue();
|
||||
var _alp = inputs[| 11].getValue();
|
||||
|
||||
var _surf_prev = outputs[| 1].getValue();
|
||||
_surf_prev = surface_verify(_surf_prev, _dim[0], _dim[1], attrDepth());
|
||||
|
@ -558,7 +566,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
BLEND_ALPHA;
|
||||
if(isUsingTool(1))
|
||||
gpu_set_blendmode(bm_subtract);
|
||||
draw_surface_ext_safe(drawing_surface, 0, 0, 1, 1, 0, c_white, tool_attribute.alpha);
|
||||
draw_surface_ext_safe(drawing_surface, 0, 0, 1, 1, 0, c_white, _alp);
|
||||
BLEND_NORMAL;
|
||||
|
||||
draw_set_color(_col);
|
||||
|
|
|
@ -305,7 +305,7 @@ function Node_Image_Sheet(_x, _y, _group = noone) : Node(_x, _y, _group) constru
|
|||
|
||||
var filSize = 4;
|
||||
var _empS = surface_create_valid(filSize, filSize, cDep);
|
||||
var _buff = buffer_create(filSize * filSize * surface_bit_size(cDep), buffer_fixed, 2);
|
||||
var _buff = buffer_create(filSize * filSize * surface_format_get_bytes(cDep), buffer_fixed, 2);
|
||||
|
||||
surf_array = [];
|
||||
for( var i = 0; i < array_length(surf_array); i++ ) {
|
||||
|
|
|
@ -532,6 +532,12 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor {
|
|||
addNodeObject(values, "Atlas Get", s_node_atlas_get, "Node_Atlas_Get", [1, Node_Atlas_Get]).setVersion(1141);
|
||||
addNodeObject(values, "Atlas Set", s_node_atlas_set, "Node_Atlas_Set", [1, Node_Atlas_Set]).setVersion(1141);
|
||||
|
||||
ds_list_add(values, "Surface");
|
||||
addNodeObject(values, "Surface from Buffer", s_node_surface_from_buffer, "Node_Surface_From_Buffer", [1, Node_Surface_From_Buffer], ["buffer to surface"], "Create surface from buffer.").setVersion(1146);
|
||||
|
||||
ds_list_add(values, "Buffer");
|
||||
addNodeObject(values, "Buffer from Surface", s_node_surface_to_buffer, "Node_Surface_To_Buffer", [1, Node_Surface_To_Buffer], ["surface to buffer"], "Create buffer from surface.").setVersion(1146);
|
||||
|
||||
var color = ds_list_create();
|
||||
addNodeCatagory("Color", color);
|
||||
ds_list_add(color, "Colors");
|
||||
|
|
|
@ -35,7 +35,10 @@ function Node_Struct_Get(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
|||
if(instanceof(val) == "Surface") {
|
||||
out.type = VALUE_TYPE.surface;
|
||||
val = val.get();
|
||||
} else
|
||||
} else if(instanceof(val) == "Buffer") {
|
||||
out.type = VALUE_TYPE.buffer;
|
||||
val = val.buffer;
|
||||
} else
|
||||
out.type = VALUE_TYPE.struct;
|
||||
} else if(is_array(val) && array_length(val))
|
||||
out.type = is_string(val[0])? VALUE_TYPE.text : VALUE_TYPE.float;
|
||||
|
|
12
scripts/node_surface_from_buffer/node_counter.yy
Normal file
12
scripts/node_surface_from_buffer/node_counter.yy
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"isDnD": false,
|
||||
"isCompatibility": false,
|
||||
"parent": {
|
||||
"name": "number",
|
||||
"path": "folders/nodes/data/number.yy",
|
||||
},
|
||||
"resourceVersion": "1.0",
|
||||
"name": "node_counter",
|
||||
"tags": [],
|
||||
"resourceType": "GMScript",
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
function Node_Surface_From_Buffer(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
||||
name = "Surface from Buffer";
|
||||
|
||||
inputs[| 0] = nodeValue("Buffer", self, JUNCTION_CONNECT.input, VALUE_TYPE.buffer, noone)
|
||||
.setVisible(true, true);
|
||||
|
||||
outputs[| 0] = nodeValue("Surface", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||
|
||||
static process_data = function(_outSurf, _data, _output_index, _array_index) {
|
||||
var _buff = _data[0];
|
||||
var _surf = surface_from_buffer(_buff);
|
||||
return _surf;
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"resourceType": "GMScript",
|
||||
"resourceVersion": "1.0",
|
||||
"name": "buffer_function",
|
||||
"name": "node_surface_from_buffer",
|
||||
"isCompatibility": false,
|
||||
"isDnD": false,
|
||||
"parent": {
|
||||
"name": "surface",
|
||||
"path": "folders/functions/surface.yy",
|
||||
"path": "folders/nodes/data/value/surface.yy",
|
||||
},
|
||||
}
|
12
scripts/node_surface_to_buffer/node_counter.yy
Normal file
12
scripts/node_surface_to_buffer/node_counter.yy
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"isDnD": false,
|
||||
"isCompatibility": false,
|
||||
"parent": {
|
||||
"name": "number",
|
||||
"path": "folders/nodes/data/number.yy",
|
||||
},
|
||||
"resourceVersion": "1.0",
|
||||
"name": "node_counter",
|
||||
"tags": [],
|
||||
"resourceType": "GMScript",
|
||||
}
|
12
scripts/node_surface_to_buffer/node_surface_to_buffer.gml
Normal file
12
scripts/node_surface_to_buffer/node_surface_to_buffer.gml
Normal file
|
@ -0,0 +1,12 @@
|
|||
function Node_Surface_To_Buffer(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
||||
name = "Buffer from Surface";
|
||||
|
||||
inputs[| 0] = nodeValue("Surface", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
|
||||
|
||||
outputs[| 0] = nodeValue("Buffer", self, JUNCTION_CONNECT.output, VALUE_TYPE.buffer, noone);
|
||||
|
||||
static process_data = function(_outSurf, _data, _output_index, _array_index) {
|
||||
var _surf = _data[0];
|
||||
return buffer_from_surface(_surf);
|
||||
}
|
||||
}
|
11
scripts/node_surface_to_buffer/node_surface_to_buffer.yy
Normal file
11
scripts/node_surface_to_buffer/node_surface_to_buffer.yy
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"resourceType": "GMScript",
|
||||
"resourceVersion": "1.0",
|
||||
"name": "node_surface_to_buffer",
|
||||
"isCompatibility": false,
|
||||
"isDnD": false,
|
||||
"parent": {
|
||||
"name": "buffer",
|
||||
"path": "folders/nodes/data/value/buffer.yy",
|
||||
},
|
||||
}
|
|
@ -10,7 +10,7 @@ function Node_Surface_To_Color(_x, _y, _group = noone) : Node_Processor(_x, _y,
|
|||
var _surf = _data[0];
|
||||
var _pal = [];
|
||||
|
||||
var buff = buffer_from_surface(_surf);
|
||||
var buff = buffer_from_surface(_surf, false);
|
||||
var size = buffer_get_size(buff);
|
||||
buffer_seek(buff, buffer_seek_start, 0);
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ enum VALUE_TYPE {
|
|||
d3vertex = 21,
|
||||
gradient = 22,
|
||||
armature = 23,
|
||||
buffer = 24,
|
||||
|
||||
action = 99,
|
||||
}
|
||||
|
@ -111,6 +112,7 @@ function value_color(i) {
|
|||
#c1007c, //d3vertex
|
||||
$5dde8f, //gradient
|
||||
$6691ff, //armature
|
||||
$808080, //buffer
|
||||
];
|
||||
|
||||
if(i == 99) return $5dde8f;
|
||||
|
@ -139,10 +141,12 @@ function value_bit(i) {
|
|||
case VALUE_TYPE.strands : return 1 << 20;
|
||||
case VALUE_TYPE.mesh : return 1 << 21;
|
||||
case VALUE_TYPE.atlas : return 1 << 23;
|
||||
case VALUE_TYPE.armature : return 1 << 24 | 1 << 19;
|
||||
case VALUE_TYPE.armature : return 1 << 26 | 1 << 19;
|
||||
|
||||
case VALUE_TYPE.node : return 1 << 32;
|
||||
|
||||
case VALUE_TYPE.buffer : return 1 << 27;
|
||||
|
||||
case VALUE_TYPE.trigger : return 1 << 22;
|
||||
case VALUE_TYPE.action : return 1 << 22 | 1 << 3;
|
||||
|
||||
|
|
|
@ -66,8 +66,11 @@ function Node_Websocket_Receiver(_x, _y, _group = noone) : Node(_x, _y, _group)
|
|||
var socket = async_load[? "id"];
|
||||
var data = buffer_get_string(buffer);
|
||||
|
||||
data = json_parse(data);
|
||||
outputs[| 0].setValue(data);
|
||||
var _data = json_try_parse(data, noone);
|
||||
if(_data == noone) _data = { rawData: new Buffer(buffer) }
|
||||
else buffer_delete(buffer);
|
||||
|
||||
outputs[| 0].setValue(_data);
|
||||
network_trigger = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ function Node_Websocket_Sender(_x, _y, _group = noone) : Node(_x, _y, _group) co
|
|||
inputs[| 0] = nodeValue("Port", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 22800);
|
||||
|
||||
inputs[| 1] = nodeValue("Data type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
||||
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Struct", "Surface", "File" ]);
|
||||
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Struct", "Surface", "File", "Buffer" ]);
|
||||
|
||||
inputs[| 2] = nodeValue("Struct", self, JUNCTION_CONNECT.input, VALUE_TYPE.struct, {});
|
||||
|
||||
|
@ -19,8 +19,10 @@ function Node_Websocket_Sender(_x, _y, _group = noone) : Node(_x, _y, _group) co
|
|||
.nonValidate();
|
||||
|
||||
inputs[| 5] = nodeValue("Target", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "127.0.0.1");
|
||||
|
||||
input_display_list = [ 5, 0, 1, 2, 3, 4 ];
|
||||
|
||||
inputs[| 6] = nodeValue("Buffer", self, JUNCTION_CONNECT.input, VALUE_TYPE.buffer, noone);
|
||||
|
||||
input_display_list = [ 5, 0, 1, 2, 3, 4, 6 ];
|
||||
|
||||
port = 0;
|
||||
url = "";
|
||||
|
@ -74,6 +76,7 @@ function Node_Websocket_Sender(_x, _y, _group = noone) : Node(_x, _y, _group) co
|
|||
inputs[| 2].setVisible(_type == 0, _type == 0);
|
||||
inputs[| 3].setVisible(_type == 1, _type == 1);
|
||||
inputs[| 4].setVisible(_type == 2, _type == 2);
|
||||
inputs[| 6].setVisible(_type == 3, _type == 3);
|
||||
}
|
||||
|
||||
static update = function(frame = ANIMATOR.current_frame) {
|
||||
|
@ -87,25 +90,31 @@ function Node_Websocket_Sender(_x, _y, _group = noone) : Node(_x, _y, _group) co
|
|||
if(network < 0) return;
|
||||
|
||||
var _type = inputs[| 1].getValue();
|
||||
var _buff, res;
|
||||
|
||||
switch(_type) {
|
||||
case 0 :
|
||||
var _stru = inputs[| 2].getValue();
|
||||
var _str = json_stringify(_stru);
|
||||
var _buff = buffer_from_string(_str);
|
||||
var res = network_send_raw(network, _buff, buffer_get_size(_buff), network_send_text);
|
||||
_buff = buffer_from_string(_str);
|
||||
res = network_send_raw(network, _buff, buffer_get_size(_buff), network_send_text);
|
||||
break;
|
||||
case 1 :
|
||||
var _surf = inputs[| 3].getValue();
|
||||
if(!is_surface(_surf)) return;
|
||||
var _buff = buffer_from_surface(_surf);
|
||||
var res = network_send_raw(network, _buff, buffer_get_size(_buff), network_send_binary);
|
||||
_buff = buffer_from_surface(_surf);
|
||||
res = network_send_raw(network, _buff, buffer_get_size(_buff), network_send_text);
|
||||
break;
|
||||
case 2 :
|
||||
var _path = inputs[| 4].getValue();
|
||||
if(!file_exists(_path)) return;
|
||||
var _buff = buffer_from_file(_path);
|
||||
var res = network_send_raw(network, _buff, buffer_get_size(_buff), network_send_binary);
|
||||
_buff = buffer_from_file(_path);
|
||||
res = network_send_raw(network, _buff, buffer_get_size(_buff), network_send_text);
|
||||
break;
|
||||
case 3 :
|
||||
_buff = inputs[| 6].getValue();
|
||||
if(!buffer_exists(_buff)) return;
|
||||
res = network_send_raw(network, _buff, buffer_get_size(_buff), network_send_text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,6 +164,26 @@ function surface_create_from_buffer(w, h, buff, format = surface_rgba8unorm) {
|
|||
return s;
|
||||
}
|
||||
|
||||
function surface_from_buffer(buff) {
|
||||
static header_length = 24;
|
||||
if(!buffer_exists(buff)) return noone;
|
||||
|
||||
buffer_seek(buff, buffer_seek_start, 0);
|
||||
var text = "";
|
||||
repeat(4) text += chr(buffer_read(buff, buffer_u8));
|
||||
if(text != "PXCS") return noone;
|
||||
|
||||
var w = buffer_read(buff, buffer_u16);
|
||||
var h = buffer_read(buff, buffer_u16);
|
||||
var format = buffer_read(buff, buffer_u8);
|
||||
//print($"Creating surface from buffer {buff}: size {buffer_get_size(buff) - 4}: w = {w}, h = {h}");
|
||||
if(w < 1 || h < 1) return noone;
|
||||
|
||||
var s = surface_create(w, h, format);
|
||||
buffer_set_surface(buff, s, header_length);
|
||||
return s;
|
||||
}
|
||||
|
||||
function surface_create_from_sprite(spr) {
|
||||
if(!sprite_exists(spr)) return noone;
|
||||
|
||||
|
@ -361,7 +381,7 @@ function surface_decode(struct) {
|
|||
return surface_create_from_buffer(struct.width, struct.height, buff);
|
||||
}
|
||||
|
||||
function surface_bit_size(format) {
|
||||
function surface_format_get_bytes(format) {
|
||||
switch(format) {
|
||||
case surface_rgba4unorm : return 4 * 0.5; break;
|
||||
case surface_rgba8unorm : return 4 * 1; break;
|
||||
|
@ -378,6 +398,6 @@ function surface_bit_size(format) {
|
|||
function surface_get_size(surface) {
|
||||
var sw = surface_get_width(surface);
|
||||
var sh = surface_get_height(surface);
|
||||
var sz = sw * sh * surface_bit_size(surface_get_format(surface));
|
||||
var sz = sw * sh * surface_format_get_bytes(surface_get_format(surface));
|
||||
return sz;
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
|
@ -0,0 +1,74 @@
|
|||
{
|
||||
"resourceType": "GMSprite",
|
||||
"resourceVersion": "1.0",
|
||||
"name": "s_node_surface_from_buffer",
|
||||
"bbox_bottom": 63,
|
||||
"bbox_left": 7,
|
||||
"bbox_right": 56,
|
||||
"bbox_top": 1,
|
||||
"bboxMode": 0,
|
||||
"collisionKind": 1,
|
||||
"collisionTolerance": 0,
|
||||
"DynamicTexturePage": false,
|
||||
"edgeFiltering": false,
|
||||
"For3D": false,
|
||||
"frames": [
|
||||
{"resourceType":"GMSpriteFrame","resourceVersion":"1.1","name":"d6bbd497-0441-476e-9ffd-98917a581b14",},
|
||||
],
|
||||
"gridX": 0,
|
||||
"gridY": 0,
|
||||
"height": 64,
|
||||
"HTile": false,
|
||||
"layers": [
|
||||
{"resourceType":"GMImageLayer","resourceVersion":"1.0","name":"ffa6a843-41ce-4e0a-b2e3-5ee03bad902f","blendMode":0,"displayName":"default","isLocked":false,"opacity":100.0,"visible":true,},
|
||||
],
|
||||
"nineSlice": null,
|
||||
"origin": 4,
|
||||
"parent": {
|
||||
"name": "surface",
|
||||
"path": "folders/nodes/icons/value/surface.yy",
|
||||
},
|
||||
"preMultiplyAlpha": false,
|
||||
"sequence": {
|
||||
"resourceType": "GMSequence",
|
||||
"resourceVersion": "1.4",
|
||||
"name": "s_node_surface_from_buffer",
|
||||
"autoRecord": true,
|
||||
"backdropHeight": 768,
|
||||
"backdropImageOpacity": 0.5,
|
||||
"backdropImagePath": "",
|
||||
"backdropWidth": 1366,
|
||||
"backdropXOffset": 0.0,
|
||||
"backdropYOffset": 0.0,
|
||||
"events": {"resourceType":"KeyframeStore<MessageEventKeyframe>","resourceVersion":"1.0","Keyframes":[],},
|
||||
"eventStubScript": null,
|
||||
"eventToFunction": {},
|
||||
"length": 1.0,
|
||||
"lockOrigin": false,
|
||||
"moments": {"resourceType":"KeyframeStore<MomentsEventKeyframe>","resourceVersion":"1.0","Keyframes":[],},
|
||||
"playback": 1,
|
||||
"playbackSpeed": 30.0,
|
||||
"playbackSpeedType": 0,
|
||||
"showBackdrop": true,
|
||||
"showBackdropImage": false,
|
||||
"timeUnits": 1,
|
||||
"tracks": [
|
||||
{"resourceType":"GMSpriteFramesTrack","resourceVersion":"1.0","name":"frames","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"resourceType":"KeyframeStore<SpriteFrameKeyframe>","resourceVersion":"1.0","Keyframes":[
|
||||
{"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"1.0","Channels":{"0":{"resourceType":"SpriteFrameKeyframe","resourceVersion":"1.0","Id":{"name":"d6bbd497-0441-476e-9ffd-98917a581b14","path":"sprites/s_node_surface_from_buffer/s_node_surface_from_buffer.yy",},},},"Disabled":false,"id":"1b805e2c-9de1-4d29-a80a-1fed818e43ed","IsCreationKey":false,"Key":0.0,"Length":1.0,"Stretch":false,},
|
||||
],},"modifiers":[],"spriteId":null,"trackColour":0,"tracks":[],"traits":0,},
|
||||
],
|
||||
"visibleRange": null,
|
||||
"volume": 1.0,
|
||||
"xorigin": 32,
|
||||
"yorigin": 32,
|
||||
},
|
||||
"swatchColours": null,
|
||||
"swfPrecision": 2.525,
|
||||
"textureGroupId": {
|
||||
"name": "Default",
|
||||
"path": "texturegroups/Default",
|
||||
},
|
||||
"type": 0,
|
||||
"VTile": false,
|
||||
"width": 64,
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
74
sprites/s_node_surface_to_buffer/s_node_surface_to_buffer.yy
Normal file
74
sprites/s_node_surface_to_buffer/s_node_surface_to_buffer.yy
Normal file
|
@ -0,0 +1,74 @@
|
|||
{
|
||||
"resourceType": "GMSprite",
|
||||
"resourceVersion": "1.0",
|
||||
"name": "s_node_surface_to_buffer",
|
||||
"bbox_bottom": 59,
|
||||
"bbox_left": 7,
|
||||
"bbox_right": 56,
|
||||
"bbox_top": 0,
|
||||
"bboxMode": 0,
|
||||
"collisionKind": 1,
|
||||
"collisionTolerance": 0,
|
||||
"DynamicTexturePage": false,
|
||||
"edgeFiltering": false,
|
||||
"For3D": false,
|
||||
"frames": [
|
||||
{"resourceType":"GMSpriteFrame","resourceVersion":"1.1","name":"7907bdbf-99ba-4284-b143-d27f8a3f90b1",},
|
||||
],
|
||||
"gridX": 0,
|
||||
"gridY": 0,
|
||||
"height": 64,
|
||||
"HTile": false,
|
||||
"layers": [
|
||||
{"resourceType":"GMImageLayer","resourceVersion":"1.0","name":"5f7b0970-db24-47c2-bd3c-555b603c163a","blendMode":0,"displayName":"default","isLocked":false,"opacity":100.0,"visible":true,},
|
||||
],
|
||||
"nineSlice": null,
|
||||
"origin": 4,
|
||||
"parent": {
|
||||
"name": "surface",
|
||||
"path": "folders/nodes/icons/value/surface.yy",
|
||||
},
|
||||
"preMultiplyAlpha": false,
|
||||
"sequence": {
|
||||
"resourceType": "GMSequence",
|
||||
"resourceVersion": "1.4",
|
||||
"name": "s_node_surface_to_buffer",
|
||||
"autoRecord": true,
|
||||
"backdropHeight": 768,
|
||||
"backdropImageOpacity": 0.5,
|
||||
"backdropImagePath": "",
|
||||
"backdropWidth": 1366,
|
||||
"backdropXOffset": 0.0,
|
||||
"backdropYOffset": 0.0,
|
||||
"events": {"resourceType":"KeyframeStore<MessageEventKeyframe>","resourceVersion":"1.0","Keyframes":[],},
|
||||
"eventStubScript": null,
|
||||
"eventToFunction": {},
|
||||
"length": 1.0,
|
||||
"lockOrigin": false,
|
||||
"moments": {"resourceType":"KeyframeStore<MomentsEventKeyframe>","resourceVersion":"1.0","Keyframes":[],},
|
||||
"playback": 1,
|
||||
"playbackSpeed": 30.0,
|
||||
"playbackSpeedType": 0,
|
||||
"showBackdrop": true,
|
||||
"showBackdropImage": false,
|
||||
"timeUnits": 1,
|
||||
"tracks": [
|
||||
{"resourceType":"GMSpriteFramesTrack","resourceVersion":"1.0","name":"frames","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"resourceType":"KeyframeStore<SpriteFrameKeyframe>","resourceVersion":"1.0","Keyframes":[
|
||||
{"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"1.0","Channels":{"0":{"resourceType":"SpriteFrameKeyframe","resourceVersion":"1.0","Id":{"name":"7907bdbf-99ba-4284-b143-d27f8a3f90b1","path":"sprites/s_node_surface_to_buffer/s_node_surface_to_buffer.yy",},},},"Disabled":false,"id":"c7fcd9ed-b3f5-4a96-aa20-225508348f0c","IsCreationKey":false,"Key":0.0,"Length":1.0,"Stretch":false,},
|
||||
],},"modifiers":[],"spriteId":null,"trackColour":0,"tracks":[],"traits":0,},
|
||||
],
|
||||
"visibleRange": null,
|
||||
"volume": 1.0,
|
||||
"xorigin": 32,
|
||||
"yorigin": 32,
|
||||
},
|
||||
"swatchColours": null,
|
||||
"swfPrecision": 2.525,
|
||||
"textureGroupId": {
|
||||
"name": "Default",
|
||||
"path": "texturegroups/Default",
|
||||
},
|
||||
"type": 0,
|
||||
"VTile": false,
|
||||
"width": 64,
|
||||
}
|
Loading…
Reference in a new issue