mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-02-13 13:50:29 +01:00
[Add node] Improve search weight for consecutive matches.
This commit is contained in:
parent
2f424e6284
commit
a1a4476c41
6 changed files with 63 additions and 38 deletions
|
@ -989,6 +989,7 @@ event_inherited();
|
||||||
|
|
||||||
if(!struct_has(cat, "list"))
|
if(!struct_has(cat, "list"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(array_length(cat.filter) && !array_exists(cat.filter, instanceof(context)))
|
if(array_length(cat.filter) && !array_exists(cat.filter, instanceof(context)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
LATEST_VERSION = 1_18_00_0;
|
LATEST_VERSION = 1_18_00_0;
|
||||||
VERSION = 1_18_06_2;
|
VERSION = 1_18_06_2;
|
||||||
SAVE_VERSION = 1_18_05_0;
|
SAVE_VERSION = 1_18_05_0;
|
||||||
VERSION_STRING = MAC? "1.18.003m" : "1.18.7.001";
|
VERSION_STRING = MAC? "1.18.003m" : "1.18.7.002";
|
||||||
BUILD_NUMBER = 1_18_06_2;
|
BUILD_NUMBER = 1_18_06_2;
|
||||||
PREF_VERSION = 1_17_1;
|
PREF_VERSION = 1_17_1;
|
||||||
|
|
||||||
|
|
|
@ -1095,6 +1095,7 @@ function __initNodes() {
|
||||||
addNodeObject(values, "Atlas to Struct", Node_Atlas_Struct, "Convert atlas into generic struct.").setVersion(11710);
|
addNodeObject(values, "Atlas to Struct", Node_Atlas_Struct, "Convert atlas into generic struct.").setVersion(11710);
|
||||||
|
|
||||||
ds_list_add(values, "Surface");
|
ds_list_add(values, "Surface");
|
||||||
|
addNodeObject(values, "Surface Data", Node_Surface_data, "Extract information about a surface").setTags(["surface info"]).setVersion(1_18_07_0);
|
||||||
// addNodeObject(values, "Dynamic Surface", Node_dynaSurf).setVersion(11520);
|
// addNodeObject(values, "Dynamic Surface", Node_dynaSurf).setVersion(11520);
|
||||||
addNodeObject(values, "IsoSurf", Node_IsoSurf, "Create a dynamic surface that changes its texture based on rotation.").setVersion(11520);
|
addNodeObject(values, "IsoSurf", Node_IsoSurf, "Create a dynamic surface that changes its texture based on rotation.").setVersion(11520);
|
||||||
addNodeObject(values, "Surface from Buffer", Node_Surface_From_Buffer, "Create surface from a valid buffer.").setTags(["buffer to surface"]).setVersion(1146);
|
addNodeObject(values, "Surface from Buffer", Node_Surface_From_Buffer, "Create surface from a valid buffer.").setTags(["buffer to surface"]).setVersion(1146);
|
||||||
|
|
|
@ -1,35 +1,43 @@
|
||||||
function Node_Surface_data(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
function Node_Surface_data(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
||||||
name = "Surface data";
|
name = "Surface data";
|
||||||
color = COLORS.node_blend_number;
|
color = COLORS.node_blend_number;
|
||||||
|
|
||||||
newInput(0, nodeValue_Surface("Surface", self));
|
newInput(0, nodeValue_Surface("Surface", self));
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
newOutput(0, nodeValue_Output("Dimension", self, VALUE_TYPE.integer, [ 1, 1 ]))
|
newOutput(0, nodeValue_Output("Dimension", self, VALUE_TYPE.integer, [ 1, 1 ]))
|
||||||
.setDisplay(VALUE_DISPLAY.vector);
|
.setDisplay(VALUE_DISPLAY.vector);
|
||||||
|
|
||||||
newOutput(1, nodeValue_Output("Array length", self, VALUE_TYPE.integer, 0));
|
newOutput(1, nodeValue_Output("Width", self, VALUE_TYPE.integer, 1));
|
||||||
|
|
||||||
|
newOutput(2, nodeValue_Output("Height", self, VALUE_TYPE.integer, 1));
|
||||||
|
|
||||||
|
newOutput(3, nodeValue_Output("Format String", self, VALUE_TYPE.text, ""))
|
||||||
|
.setVisible(false);
|
||||||
|
|
||||||
|
newOutput(4, nodeValue_Output("Bit Depth", self, VALUE_TYPE.integer, 8))
|
||||||
|
.setVisible(false);
|
||||||
|
|
||||||
|
newOutput(5, nodeValue_Output("Channels", self, VALUE_TYPE.integer, 4))
|
||||||
|
.setVisible(false);
|
||||||
|
|
||||||
setDimension(96, 48);
|
setDimension(96, 48);
|
||||||
|
|
||||||
static update = function(frame = CURRENT_FRAME) {
|
static processData = function(_outData, _data, _output_index, _array_index = 0) {
|
||||||
var _insurf = getInputData(0);
|
var _surf = _data[0];
|
||||||
if(is_array(_insurf)) {
|
if(!is_surface(_surf)) return _outData;
|
||||||
var len = array_length(_insurf);
|
|
||||||
var _dim = array_create(len);
|
|
||||||
|
|
||||||
for( var i = 0; i < len; i++ ) {
|
var _dim = surface_get_dimension(_surf);
|
||||||
_dim[i][0] = surface_get_width_safe(_insurf[i]);
|
_outData[0] = _dim;
|
||||||
_dim[i][1] = surface_get_height_safe(_insurf[i]);
|
_outData[1] = _dim[0];
|
||||||
}
|
_outData[2] = _dim[1];
|
||||||
|
|
||||||
outputs[0].setValue(_dim);
|
var _frm = surface_get_format(_surf);
|
||||||
outputs[1].setValue(len);
|
_outData[3] = surface_format_string(_frm);
|
||||||
return;
|
_outData[4] = surface_format_get_depth(_frm);
|
||||||
}
|
_outData[5] = surface_format_get_channel(_frm);
|
||||||
|
|
||||||
if(!_insurf || !surface_exists(_insurf)) return;
|
return _outData;
|
||||||
|
|
||||||
outputs[0].setValue([ surface_get_width_safe(_insurf), surface_get_height_safe(_insurf) ]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -133,47 +133,48 @@ function string_partial_match(str, key) {
|
||||||
return -9999;
|
return -9999;
|
||||||
}
|
}
|
||||||
|
|
||||||
function string_partial_match_res(str, key, keys) {
|
function string_partial_match_res(str, key, keys = []) {
|
||||||
if(str == key) return [ 9999, array_create(string_length(str) + 1, 1) ];
|
if(str == key) return [ 9999, array_create(string_length(str) + 1, 1) ];
|
||||||
|
|
||||||
var lenn = string_length(str);
|
var lenn = string_length(str);
|
||||||
var lenm = string_length(key);
|
var lenm = string_length(key);
|
||||||
var runm = 1;
|
var runm = 1;
|
||||||
|
|
||||||
var _minmat = -lenn * lenm;
|
var _matchw = -lenn * lenm;
|
||||||
var _matRng = array_create(string_length(str) + 1, 0);
|
var _matRng = array_create(string_length(str) + 1, 0);
|
||||||
var _mated = array_create(string_length(str) + 1, 0);
|
var _mated = array_create(string_length(str) + 1, 0);
|
||||||
|
var runn = 1;
|
||||||
|
var runC = 0;
|
||||||
|
|
||||||
while(runm <= lenm) {
|
repeat(lenm) {
|
||||||
var m = string_char_at(key, runm);
|
var m = string_char_at(key, runm);
|
||||||
|
|
||||||
var runn = 1;
|
|
||||||
var matc = -1;
|
var matc = -1;
|
||||||
while(runn <= lenn) {
|
var matW = 0;
|
||||||
|
|
||||||
|
repeat(lenn) {
|
||||||
var n = string_char_at(str, runn);
|
var n = string_char_at(str, runn);
|
||||||
if(_mated[runn] == 0 && m == n) {
|
if(_mated[runn] == 0 && m == n) {
|
||||||
matc = runn;
|
matc = runn;
|
||||||
_minmat += lenn - abs(runm - runn);
|
_matchw += lenn - matW + (matW == 0) * runC * 5;
|
||||||
|
|
||||||
if(runn > 1 && string_char_at(str, runn - 1) == " ")
|
|
||||||
_minmat += 2;
|
|
||||||
|
|
||||||
_mated[runn] = 1;
|
_mated[runn] = 1;
|
||||||
_matRng[runn] = 1;
|
_matRng[runn] = 1;
|
||||||
break;
|
|
||||||
}
|
|
||||||
runn++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(matc == -1) {
|
runC = matW == 0? runC + 1 : 0;
|
||||||
_minmat = -9999;
|
if(++runn > lenn) runn = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
matW++;
|
||||||
|
if(++runn > lenn) runn = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(matc == -1) { _matchw = -9999; break; }
|
||||||
runm++
|
runm++
|
||||||
}
|
}
|
||||||
|
|
||||||
return [ _minmat, _matRng ];
|
return [ _matchw, _matRng ];
|
||||||
}
|
}
|
||||||
|
|
||||||
function __string_partial_match_res(str, key, keys) {
|
function __string_partial_match_res(str, key, keys) {
|
||||||
|
|
|
@ -537,6 +537,20 @@ function surface_reset_target_override() { __surface_reset_target(); winwin_draw
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function surface_format_get_depth(format) {
|
||||||
|
switch(format) {
|
||||||
|
case surface_rgba4unorm : return 4; break;
|
||||||
|
case surface_rgba8unorm : return 8; break;
|
||||||
|
case surface_rgba16float : return 16; break
|
||||||
|
case surface_rgba32float : return 32; break;
|
||||||
|
|
||||||
|
case surface_r8unorm : return 8; break
|
||||||
|
case surface_r16float : return 16; break
|
||||||
|
case surface_r32float : return 32; break;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
function surface_format_get_bytes(format) {
|
function surface_format_get_bytes(format) {
|
||||||
switch(format) {
|
switch(format) {
|
||||||
case surface_rgba4unorm : return 4 * 0.5; break;
|
case surface_rgba4unorm : return 4 * 0.5; break;
|
||||||
|
|
Loading…
Reference in a new issue