mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-01-23 19:38:05 +01:00
Replace image
This commit is contained in:
parent
96fb8a513f
commit
edd2a86779
8 changed files with 76 additions and 28 deletions
|
@ -473,6 +473,7 @@
|
|||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_textbox.png","CopyToMask":-1,"filePath":"datafiles/data/themes/Cornerless/graphics/widget",},
|
||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_widget_highlight.png","CopyToMask":-1,"filePath":"datafiles/data/themes/Cornerless/graphics/widget",},
|
||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"values.json","CopyToMask":-1,"filePath":"datafiles/data/themes/Cornerless",},
|
||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"default.zip","CopyToMask":-1,"filePath":"datafiles/data/themes",},
|
||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"FiraCode-Medium.ttf","CopyToMask":-1,"filePath":"datafiles/data/themes/default/fonts",},
|
||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"fonts.json","CopyToMask":-1,"filePath":"datafiles/data/themes/default/fonts",},
|
||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"NotoSans-Black.ttf","CopyToMask":-1,"filePath":"datafiles/data/themes/default/fonts",},
|
||||
|
@ -562,6 +563,7 @@
|
|||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_node_create.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
|
||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_node_goto.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
|
||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_node_move.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
|
||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_node_name_type.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
|
||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_node_processor.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
|
||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_node_resize.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
|
||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_node_use_global.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
|
||||
|
@ -753,7 +755,6 @@
|
|||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_textbox.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/widget",},
|
||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_widget_highlight.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/widget",},
|
||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"values.json","CopyToMask":-1,"filePath":"datafiles/data/themes/default",},
|
||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"theme.zip","CopyToMask":-1,"filePath":"datafiles/data/themes",},
|
||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"tooltip.zip","CopyToMask":3035426170322551022,"filePath":"datafiles/data",},
|
||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"0 introduction.png","CopyToMask":-1,"filePath":"datafiles/Getting started",},
|
||||
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"0 introduction.pxc","CopyToMask":-1,"filePath":"datafiles/Getting started",},
|
||||
|
|
Binary file not shown.
|
@ -37,7 +37,7 @@
|
|||
SAVEFILE_VERSION = 1400;
|
||||
COLLECTION_VERSION = 1140.090;
|
||||
THEME_VERSION = 1140.090;
|
||||
VERSION_STRING = "1.14.0pr9.3";
|
||||
VERSION_STRING = "1.14.0pr9.4";
|
||||
|
||||
globalvar NODES, NODE_MAP, APPEND_MAP, HOTKEYS, HOTKEY_CONTEXT, NODE_INSTANCES;
|
||||
|
||||
|
|
|
@ -19,11 +19,16 @@ function Node_Surface_Replace(_x, _y, _group = noone) : Node_Processor(_x, _y, _
|
|||
|
||||
inputs[| 6] = nodeValue("Pixel Threshold", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.1, "How many pixel need to me matched to replace with replacement image." )
|
||||
.setDisplay(VALUE_DISPLAY.slider, [ 0, 1, 0.01 ]);
|
||||
|
||||
|
||||
inputs[| 7] = nodeValue("Array mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
||||
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Match index", "Randomized" ], { update_hover: false });
|
||||
|
||||
inputs[| 8] = nodeValue("Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, irandom_range(10000, 99999));
|
||||
|
||||
outputs[| 0] = nodeValue("Surface Out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||
|
||||
input_display_list = [
|
||||
["Surface", true], 0, 1, 2,
|
||||
["Surface", true], 0, 1, 2, 7, 8,
|
||||
["Searching", false], 5, 3, 6,
|
||||
["Render", false], 4,
|
||||
];
|
||||
|
@ -32,12 +37,18 @@ function Node_Surface_Replace(_x, _y, _group = noone) : Node_Processor(_x, _y, _
|
|||
|
||||
static matchTemplate = function(_index, _surf, _base, _target, _cthr, _pthr, _fst) {
|
||||
surface_set_shader(_surf, _fst? sh_surface_replace_fast_find : sh_surface_replace_find, false);
|
||||
shader_set_f("dimension", surface_get_width(_base), surface_get_height(_base));
|
||||
shader_set_surface("target", _target);
|
||||
shader_set_f("target_dim", surface_get_width(_target), surface_get_height(_target));
|
||||
shader_set_f("dimension", surface_get_width(_base), surface_get_height(_base));
|
||||
shader_set_surface("target", _target);
|
||||
shader_set_f("target_dim", surface_get_width(_target), surface_get_height(_target));
|
||||
shader_set_f("colorThreshold", _cthr);
|
||||
shader_set_f("pixelThreshold", _pthr);
|
||||
shader_set_f("index", _index);
|
||||
shader_set_i("mode", inputs[| 7].getValue());
|
||||
shader_set_f("seed", inputs[| 8].getValue());
|
||||
|
||||
var dest = inputs[| 2].getValue();
|
||||
var size = is_array(dest)? array_length(dest) : 1;
|
||||
shader_set_f("size", size);
|
||||
|
||||
BLEND_ADD
|
||||
draw_surface_safe(_base);
|
||||
|
@ -57,6 +68,11 @@ function Node_Surface_Replace(_x, _y, _group = noone) : Node_Processor(_x, _y, _
|
|||
surface_reset_shader();
|
||||
}
|
||||
|
||||
static step = function() {
|
||||
var _mode = inputs[| 7].getValue();
|
||||
inputs[| 8].setVisible(_mode == 1);
|
||||
}
|
||||
|
||||
static process_data = function(_outSurf, _data, _output_index, _array_index) {
|
||||
var _bas = _data[0];
|
||||
var _tar = _data[1];
|
||||
|
@ -67,7 +83,7 @@ function Node_Surface_Replace(_x, _y, _group = noone) : Node_Processor(_x, _y, _
|
|||
var _cthr = _data[3];
|
||||
var _pthr = _data[6];
|
||||
|
||||
if(!is_array(_tar)) _tar = [ _tar ];
|
||||
if(!is_array(_tar)) _tar = [ _tar ];
|
||||
if(!is_array(_rep)) _rep = [ _rep ];
|
||||
|
||||
temp_surface[0] = surface_verify(temp_surface[0], surface_get_width(_bas), surface_get_height(_bas));
|
||||
|
@ -78,6 +94,7 @@ function Node_Surface_Replace(_x, _y, _group = noone) : Node_Processor(_x, _y, _
|
|||
var amo = array_length(_tar);
|
||||
for( var i = 0; i < amo; i++ )
|
||||
matchTemplate(i / amo, temp_surface[0], _bas, _tar[i], _cthr, _pthr, _fst);
|
||||
//return temp_surface[0];
|
||||
|
||||
_outSurf = surface_verify(_outSurf, surface_get_width(_bas), surface_get_height(_bas));
|
||||
surface_set_target(_outSurf);
|
||||
|
|
|
@ -73,6 +73,7 @@ function Panel_Animation() : PanelContent() constructor {
|
|||
|
||||
node_ordering = noone;
|
||||
show_node_outside_context = true;
|
||||
node_name_type = 0;
|
||||
|
||||
stagger_mode = 0;
|
||||
stagger_index = 0;
|
||||
|
@ -956,12 +957,18 @@ function Panel_Animation() : PanelContent() constructor {
|
|||
var tw = string_width(nodeName);
|
||||
|
||||
draw_set_color(node_ordering == _node? COLORS._main_text_accent : COLORS._main_text);
|
||||
var txx = ui(20);
|
||||
|
||||
draw_set_alpha(0.4);
|
||||
draw_text(ui(20), _node_y - ui(2), nodeName);
|
||||
if(node_name_type == 0 || node_name_type == 1 || _node.display_name == "") {
|
||||
draw_set_alpha(0.4);
|
||||
draw_text(txx, _node_y - ui(2), nodeName);
|
||||
txx += tw;
|
||||
}
|
||||
|
||||
draw_set_alpha(0.9);
|
||||
draw_text(ui(20) + tw, _node_y - ui(2), _node.display_name);
|
||||
if(node_name_type == 0 || node_name_type == 2) {
|
||||
draw_set_alpha(0.9);
|
||||
draw_text(txx, _node_y - ui(2), _node.display_name);
|
||||
}
|
||||
|
||||
draw_set_alpha(1);
|
||||
|
||||
|
@ -1647,6 +1654,17 @@ function Panel_Animation() : PanelContent() constructor {
|
|||
var txt = show_node_outside_context? get_text("panel_animation_hide_node", "Hide node outside context") : get_text("panel_animation_show_node", "Show node outside context");
|
||||
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(24), [mx, my], pFOCUS, pHOVER, txt, THEME.junc_visible, show_node_outside_context) == 2)
|
||||
show_node_outside_context = !show_node_outside_context;
|
||||
|
||||
by += ui(28);
|
||||
var txt = "";
|
||||
switch(node_name_type) {
|
||||
case 0 : txt = get_text("panel_animation_name_full", "Show full name"); break;
|
||||
case 1 : txt = get_text("panel_animation_name_type", "Show node type"); break;
|
||||
case 2 : txt = get_text("panel_animation_name_only", "Show node name"); break;
|
||||
}
|
||||
|
||||
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(24), [mx, my], pFOCUS, pHOVER, txt, THEME.node_name_type) == 2)
|
||||
node_name_type = (node_name_type + 1) % 3;
|
||||
}
|
||||
|
||||
function drawContent(panel) {
|
||||
|
|
|
@ -4,14 +4,14 @@ function __initTheme() {
|
|||
directory_create(root);
|
||||
|
||||
var _l = root + "/version";
|
||||
if(file_exists(_l)) {
|
||||
var res = json_load_struct(_l);
|
||||
if(res.version == THEME_VERSION) return;
|
||||
}
|
||||
//if(file_exists(_l)) {
|
||||
// var res = json_load_struct(_l);
|
||||
// if(res.version == THEME_VERSION) return;
|
||||
//}
|
||||
json_save_struct(_l, { version: THEME_VERSION });
|
||||
|
||||
log_message("THEME", "unzipping default theme to DIRECTORY.");
|
||||
zip_unzip("data/themes/theme.zip", root);
|
||||
zip_unzip("data/themes/default.zip", root);
|
||||
}
|
||||
|
||||
function _sprite_path(rel, theme) {
|
||||
|
|
|
@ -11,6 +11,13 @@ uniform float colorThreshold;
|
|||
uniform float pixelThreshold;
|
||||
uniform float index;
|
||||
|
||||
uniform int mode;
|
||||
uniform float seed;
|
||||
uniform float size;
|
||||
|
||||
float random (in vec2 st) { return fract(sin(dot(st.xy + seed, vec2(12.9898, 78.233))) * 43758.5453123); }
|
||||
float round(float val) { return fract(val) > 0.5? ceil(val) : floor(val); }
|
||||
|
||||
void main() {
|
||||
vec4 base = texture2D( gm_BaseTexture, v_vTexcoord );
|
||||
if(base.a == 0.) {
|
||||
|
@ -47,7 +54,7 @@ void main() {
|
|||
}
|
||||
|
||||
if(match / content_px >= (1. - pixelThreshold)) {
|
||||
gl_FragColor = vec4(1., index, 0., 1.);
|
||||
return;
|
||||
float ind = mode == 0? index : round(random(v_vTexcoord) * (size - 1.)) / size;
|
||||
gl_FragColor = vec4(1., ind, 0., 1.);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,14 +11,18 @@ uniform float colorThreshold;
|
|||
uniform float pixelThreshold;
|
||||
uniform float index;
|
||||
|
||||
float random (in vec2 st) {
|
||||
return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123);
|
||||
}
|
||||
uniform int mode;
|
||||
uniform float seed;
|
||||
uniform float size;
|
||||
|
||||
float random (in vec2 st) { return fract(sin(dot(st.xy + seed, vec2(12.9898, 78.233))) * 43758.5453123); }
|
||||
float round(float val) { return fract(val) > 0.5? ceil(val) : floor(val); }
|
||||
|
||||
vec2 baseTx = 1. / dimension;
|
||||
vec2 targTx = 1. / target_dim;
|
||||
|
||||
float matchTemplate(vec2 pos) {
|
||||
float match = 0.;
|
||||
vec2 baseTx = 1. / dimension;
|
||||
vec2 targTx = 1. / target_dim;
|
||||
float _match = 0.;
|
||||
float content_px = 0.;
|
||||
|
||||
for( float i = 0.; i < target_dim.x; i++ )
|
||||
|
@ -31,10 +35,10 @@ float matchTemplate(vec2 pos) {
|
|||
|
||||
content_px++;
|
||||
if(distance(base, targ) <= 2. * colorThreshold)
|
||||
match++;
|
||||
_match++;
|
||||
}
|
||||
|
||||
return match / content_px;
|
||||
return _match / content_px;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
@ -64,5 +68,6 @@ void main() {
|
|||
}
|
||||
}
|
||||
|
||||
gl_FragColor = match >= (1. - pixelThreshold)? vec4(matchPos, index, 1.) : vec4(vec3(0.), 0.);
|
||||
float ind = mode == 0? index : round(random(matchUv) * (size - 1.)) / size;
|
||||
gl_FragColor = match > (1. - pixelThreshold - 1. / (target_dim.x * target_dim.y))? vec4(matchPos, ind, 1.) : vec4(0.);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue