mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-02-13 05:35:23 +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"))
|
||||
continue;
|
||||
|
||||
if(array_length(cat.filter) && !array_exists(cat.filter, instanceof(context)))
|
||||
continue;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
LATEST_VERSION = 1_18_00_0;
|
||||
VERSION = 1_18_06_2;
|
||||
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;
|
||||
PREF_VERSION = 1_17_1;
|
||||
|
||||
|
|
|
@ -1095,7 +1095,8 @@ function __initNodes() {
|
|||
addNodeObject(values, "Atlas to Struct", Node_Atlas_Struct, "Convert atlas into generic struct.").setVersion(11710);
|
||||
|
||||
ds_list_add(values, "Surface");
|
||||
//addNodeObject(values, "Dynamic Surface", Node_dynaSurf).setVersion(11520);
|
||||
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, "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);
|
||||
|
||||
|
|
|
@ -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";
|
||||
color = COLORS.node_blend_number;
|
||||
|
||||
newInput(0, nodeValue_Surface("Surface", self));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
newOutput(0, nodeValue_Output("Dimension", self, VALUE_TYPE.integer, [ 1, 1 ]))
|
||||
.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);
|
||||
|
||||
static update = function(frame = CURRENT_FRAME) {
|
||||
var _insurf = getInputData(0);
|
||||
if(is_array(_insurf)) {
|
||||
var len = array_length(_insurf);
|
||||
var _dim = array_create(len);
|
||||
|
||||
for( var i = 0; i < len; i++ ) {
|
||||
_dim[i][0] = surface_get_width_safe(_insurf[i]);
|
||||
_dim[i][1] = surface_get_height_safe(_insurf[i]);
|
||||
}
|
||||
|
||||
outputs[0].setValue(_dim);
|
||||
outputs[1].setValue(len);
|
||||
return;
|
||||
}
|
||||
static processData = function(_outData, _data, _output_index, _array_index = 0) {
|
||||
var _surf = _data[0];
|
||||
if(!is_surface(_surf)) return _outData;
|
||||
|
||||
if(!_insurf || !surface_exists(_insurf)) return;
|
||||
var _dim = surface_get_dimension(_surf);
|
||||
_outData[0] = _dim;
|
||||
_outData[1] = _dim[0];
|
||||
_outData[2] = _dim[1];
|
||||
|
||||
outputs[0].setValue([ surface_get_width_safe(_insurf), surface_get_height_safe(_insurf) ]);
|
||||
var _frm = surface_get_format(_surf);
|
||||
_outData[3] = surface_format_string(_frm);
|
||||
_outData[4] = surface_format_get_depth(_frm);
|
||||
_outData[5] = surface_format_get_channel(_frm);
|
||||
|
||||
return _outData;
|
||||
}
|
||||
}
|
|
@ -133,47 +133,48 @@ function string_partial_match(str, key) {
|
|||
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) ];
|
||||
|
||||
var lenn = string_length(str);
|
||||
var lenm = string_length(key);
|
||||
var runm = 1;
|
||||
|
||||
var _minmat = -lenn * lenm;
|
||||
var _matchw = -lenn * lenm;
|
||||
var _matRng = 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 runn = 1;
|
||||
var matc = -1;
|
||||
while(runn <= lenn) {
|
||||
var matW = 0;
|
||||
|
||||
repeat(lenn) {
|
||||
var n = string_char_at(str, runn);
|
||||
if(_mated[runn] == 0 && m == n) {
|
||||
matc = runn;
|
||||
_minmat += lenn - abs(runm - runn);
|
||||
|
||||
if(runn > 1 && string_char_at(str, runn - 1) == " ")
|
||||
_minmat += 2;
|
||||
_matchw += lenn - matW + (matW == 0) * runC * 5;
|
||||
|
||||
_mated[runn] = 1;
|
||||
_matRng[runn] = 1;
|
||||
|
||||
runC = matW == 0? runC + 1 : 0;
|
||||
if(++runn > lenn) runn = 1;
|
||||
break;
|
||||
}
|
||||
runn++;
|
||||
}
|
||||
|
||||
if(matc == -1) {
|
||||
_minmat = -9999;
|
||||
break;
|
||||
|
||||
matW++;
|
||||
if(++runn > lenn) runn = 1;
|
||||
}
|
||||
|
||||
if(matc == -1) { _matchw = -9999; break; }
|
||||
runm++
|
||||
}
|
||||
|
||||
return [ _minmat, _matRng ];
|
||||
return [ _matchw, _matRng ];
|
||||
}
|
||||
|
||||
function __string_partial_match_res(str, key, keys) {
|
||||
|
|
|
@ -537,6 +537,20 @@ function surface_reset_target_override() { __surface_reset_target(); winwin_draw
|
|||
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) {
|
||||
switch(format) {
|
||||
case surface_rgba4unorm : return 4 * 0.5; break;
|
||||
|
|
Loading…
Reference in a new issue