angle dir filter

This commit is contained in:
Tanasart 2024-05-17 20:25:01 +07:00
parent 0cd6019806
commit 9881f33b1c
9 changed files with 250 additions and 185 deletions

View file

@ -73,6 +73,7 @@ function __addon_lua_setup_constants(lua, context) {
lua_add_code(lua, $"vk_pagedown = {vk_pagedown}");
lua_add_code(lua, $"vk_pause = {vk_pause}");
lua_add_code(lua, $"vk_printscreen = {vk_printscreen}");
lua_add_code(lua, $"vk_f1 = {vk_f1}");
lua_add_code(lua, $"vk_f2 = {vk_f2}");
lua_add_code(lua, $"vk_f3 = {vk_f3}");
@ -85,6 +86,7 @@ function __addon_lua_setup_constants(lua, context) {
lua_add_code(lua, $"vk_f10 = {vk_f10}");
lua_add_code(lua, $"vk_f11 = {vk_f11}");
lua_add_code(lua, $"vk_f12 = {vk_f12}");
lua_add_code(lua, $"vk_numpad0 = {vk_numpad0}");
lua_add_code(lua, $"vk_numpad1 = {vk_numpad1}");
lua_add_code(lua, $"vk_numpad2 = {vk_numpad2}");
@ -143,20 +145,18 @@ function __addon_lua_setup_constants(lua, context) {
function __addon_lua_panel_variable(lua, panel) {
lua_add_code(lua,
"Panel.mouse = {" + string(panel.mx) + ", " + string(panel.my) + "}\n" +
"Panel.mouseUI = {" + string(mouse_mx) + ", " + string(mouse_my) + "}\n" +
"Panel.x = " + string(panel.x ) + "\n" +
"Panel.y = " + string(panel.y ) + "\n" +
"Panel.w = " + string(panel.w ) + "\n" +
"Panel.h = " + string(panel.h ) + "\n" +
$"Panel.mouse = \{{panel.mx}, {panel.my}\}\n" +
$"Panel.mouseUI = \{{mouse_mx}, {mouse_my}\}\n" +
$"Panel.x = {panel.x}\n" +
$"Panel.y = {panel.y}\n" +
$"Panel.w = {panel.w}\n" +
$"Panel.h = {panel.h}\n" +
"Panel.hoverable = " + string(panel.pHOVER) + "\n" +
"Panel.clickable = " + string(panel.pFOCUS) + "\n"
);
$"Panel.hoverable = {panel.pHOVER}\n" +
$"Panel.clickable = {panel.pFOCUS}\n" +
lua_add_code(lua,
"Animator.frame_current = " + string(CURRENT_FRAME) + "\n" +
"Animator.frame_total = " + string(TOTAL_FRAMES) + "\n" +
"Animator.frame_rate = " + string(PROJECT.animator.framerate) + "\n"
$"Animator.frame_current = {CURRENT_FRAME}\n" +
$"Animator.frame_total = {TOTAL_FRAMES}\n" +
$"Animator.frame_rate = {PROJECT.animator.framerate}\n"
);
}

View file

@ -233,7 +233,7 @@
[ "__sprite_add", function(_ID, _path, _amo, rem = false, smt = false, xoff = 0, yoff = 0) {
var _addon = noone;
with(_addon_custom) if(self.ID == _ID) _addon = self;
if(_addon == noone) return 0;
if(_addon == noone) return undefined;
_path = string_replace(_path, "./", _addon.directory + "/");
return sprite_add(_path, _amo, rem, smt, xoff, yoff);
@ -792,6 +792,8 @@
case "inspector" : return PANEL_INSPECTOR;
case "main" : return PANEL_MAIN;
}
return undefined;
} ],
[ "draw_text_set_format", function(ind) {
@ -802,35 +804,37 @@
case 3 : draw_set_font(f_p2); draw_set_color(COLORS._main_text_sub); break;
case 4 : draw_set_font(f_p3); draw_set_color(COLORS._main_text_sub); break;
}
return undefined;
}],
//nodes
[ "node_get", function(nodeId) {
if(!ds_map_exists(PROJECT.nodeNameMap, nodeId)) return 0;
if(!ds_map_exists(PROJECT.nodeNameMap, nodeId)) return undefined;
return PROJECT.nodeNameMap[? nodeId];
}],
[ "node_get_input_value", function(nodeId, input) {
if(!ds_map_exists(PROJECT.nodeNameMap, nodeId)) return 0;
if(!ds_map_exists(PROJECT.nodeNameMap, nodeId)) return undefined;
var node = PROJECT.nodeNameMap[? nodeId];
if(!ds_map_exists(node.inputMap, input)) return 0;
if(!ds_map_exists(node.inputMap, input)) return undefined;
return node.inputMap[? input].getValue();
}],
[ "node_set_input_value", function(nodeId, input, value) {
if(!ds_map_exists(PROJECT.nodeNameMap, nodeId)) return 0;
if(!ds_map_exists(PROJECT.nodeNameMap, nodeId)) return undefined;
var node = PROJECT.nodeNameMap[? nodeId];
if(!ds_map_exists(node.inputMap, input)) return 0;
if(!ds_map_exists(node.inputMap, input)) return undefined;
return node.inputMap[? input].setValue(value);
}],
[ "node_get_output_value", function(nodeId, input) {
if(!ds_map_exists(PROJECT.nodeNameMap, nodeId)) return 0;
if(!ds_map_exists(PROJECT.nodeNameMap, nodeId)) return undefined;
var node = PROJECT.nodeNameMap[? nodeId];
if(!ds_map_exists(node.outputMap, input)) return 0;
if(!ds_map_exists(node.outputMap, input)) return undefined;
return node.outputMap[? input].getValue();
}],
@ -840,7 +844,8 @@
var ele = HOVERING_ELEMENT;
for( var i = 0; i < argument_count; i++ ) {
if(!struct_has(ele, argument[i])) return undefined;
if(!is_struct(ele) || !struct_has(ele, argument[i]))
return undefined;
ele = ele[$ argument[i]];
}
return ele;
@ -849,7 +854,7 @@
[ "__panel_create", function(ID, panel = "") {
var _addon = noone;
with(_addon_custom) if(self.ID == ID) _addon = self;
if(_addon == noone) return noone;
if(_addon == noone) return undefined;
var arr = variable_struct_get_names(_addon.panels);
@ -860,7 +865,7 @@
dialogPanelCall(new addonPanel(_addon, pane));
}
return noone;
return undefined;
}],
@"

View file

@ -1,6 +1,7 @@
function buttonAnchor(_onClick) : widget() constructor {
onClick = _onClick;
index = 4;
click = true;
static drawParam = function(params) {
return draw(params.x, params.y, params.w, params.h, params.m);
@ -16,17 +17,20 @@ function buttonAnchor(_onClick) : widget() constructor {
var cy = y + h / 2;
hovering = false;
var spacing = 9;
for( var i = -1; i <= 1; i++ )
for( var j = -1; j <= 1; j++ ) {
var _bx = cx + j * 9;
var _by = cy + i * 9;
var _bx = cx + j * spacing;
var _by = cy + i * spacing;
var _in = (i + 1) * 3 + (j + 1);
var _fil = is_array(index)? index[_in] : _in == index;
var hov = hover && point_in_rectangle(_m[0], _m[1], _bx - 4, _by - 4, _bx + 4, _by + 4);
var cc = hov? COLORS._main_accent : COLORS._main_icon;
var aa = 0.75 + (_in == index || hov) * 0.25;
var aa = 0.75 + (_fil || hov) * 0.25;
draw_sprite_ext(THEME.prop_anchor, _in == index, _bx, _by, 1, 1, 0, cc, aa);
draw_sprite_ext(THEME.prop_anchor, _fil, _bx, _by, 1, 1, 0, cc, aa);
if(hov) {
hovering = true;
@ -41,9 +45,7 @@ function buttonAnchor(_onClick) : widget() constructor {
}
static clone = function() { #region
var cln = new buttonAnchor();
cln.onClick = onClick;
var cln = new buttonAnchor(onClick);
return cln;
} #endregion

View file

@ -1,9 +1,18 @@
function Node_Outline(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Outline";
filtering_vl = false;
filter_button = new buttonAnchor(function(ind) {
if(mouse_press(mb_left))
filtering_vl = !attributes.filter[ind];
attributes.filter[ind] = filtering_vl;
triggerRender();
});
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
inputs[| 1] = nodeValue("Width", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY._default, { front_button : filter_button })
.setMappable(15);
inputs[| 2] = nodeValue("Color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white);
@ -61,7 +70,10 @@ function Node_Outline(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
attribute_surface_depth();
attribute_oversample();
attributes.filter = array_create(9, 1);
static step = function() { #region
var _wid = getInputData(1);
var _side = getInputData(5);
inputs[| 12].setVisible(_side == 0);
@ -84,6 +96,8 @@ function Node_Outline(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
var sam = struct_try_get(attributes, "oversample");
var _crop = _data[12];
filter_button.index = attributes.filter;
surface_set_shader(_outSurf, sh_outline);
shader_set_f("dimension", ww, hh);
shader_set_f_map("borderSize", _data[1], _data[15], inputs[| 1]);
@ -97,6 +111,7 @@ function Node_Outline(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
shader_set_f_map("blend_alpha", _data[4], _data[16], inputs[| 4]);
shader_set_i("sampleMode", sam);
shader_set_i("crop_border", _crop);
shader_set_i("filter", attributes.filter);
draw_surface_safe(_data[0]);
surface_reset_shader();

View file

@ -90,6 +90,7 @@ enum VALUE_DISPLAY {
matrix,
path_anchor,
gradient_range,
boolean_grid,
//Curve
curve,
@ -381,6 +382,7 @@ function typeArray(_type) { #region
case VALUE_DISPLAY.puppet_control :
case VALUE_DISPLAY.matrix :
case VALUE_DISPLAY.transform :
case VALUE_DISPLAY.boolean_grid :
case VALUE_DISPLAY.curve :
@ -907,10 +909,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
if(struct_has(display_data, "slide_speed")) editWidget.setSlidable(display_data.slide_speed);
if(struct_has(display_data, "unit")) editWidget.unit = display_data.unit;
if(struct_has(display_data, "side_button")) {
editWidget.side_button = display_data.side_button;
editWidget.side_button.context = self;
}
if(struct_has(display_data, "side_button")) editWidget.side_button = display_data.side_button;
if(struct_has(display_data, "front_button")) editWidget.front_button = display_data.front_button;
extract_node = "Node_Number";
break; #endregion
@ -1128,7 +1128,18 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
if(type == VALUE_TYPE.integer) editWidget.setSlideSpeed(1 / 10);
for( var i = 0, n = array_length(animators); i < n; i++ )
animators[i].suffix = " " + string(i);
animators[i].suffix = $" {i}";
extract_node = "";
break; #endregion
case VALUE_DISPLAY.boolean_grid : #region
editWidget = new matrixGrid(_txt, display_data.size, function(index, val) {
return setValueInspector(val, index);
}, unit );
for( var i = 0, n = array_length(animators); i < n; i++ )
animators[i].suffix = $" {i}";
extract_node = "";
break; #endregion

View file

@ -436,6 +436,14 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor {
var _bs = min(h, ui(32));
if(_w - _bs > ui(100) && front_button) {
front_button.setFocusHover(active, hover);
front_button.draw(_x, _y + _h / 2 - _bs / 2, _bs, _bs, _m, THEME.button_hide);
_x += _bs + ui(4);
_w -= _bs + ui(4);
}
if(_w - _bs > ui(100) && side_button) {
side_button.setFocusHover(active, hover);
side_button.draw(_x + _w - _bs, _y + _h / 2 - _bs / 2, _bs, _bs, _m, THEME.button_hide);

View file

@ -6,7 +6,9 @@ function widget() constructor {
ihover = false;
parent = noone;
interactable = true;
side_button = noone;
front_button = noone;
hide = false;

View file

@ -18,6 +18,7 @@ uniform int side;
uniform int crop_border;
uniform int is_aa;
uniform int is_blend;
uniform int filter[9];
uniform vec2 blend_alpha;
uniform int blend_alphaUseSurf;
@ -61,6 +62,24 @@ vec4 blendColor(vec4 base, vec4 colr, float alpha) {
return col;
}
bool angleFiltered(float angle) {
float _dg = mod((degrees(angle) + 360. + ((side == 0)? 180. : 0.)), 360.);
int _ind = 0;
if(_dg <= 22.5 + 45. * 0.) _ind = 3;
else if(_dg <= 22.5 + 45. * 1.) _ind = 0;
else if(_dg <= 22.5 + 45. * 2.) _ind = 1;
else if(_dg <= 22.5 + 45. * 3.) _ind = 2;
else if(_dg <= 22.5 + 45. * 4.) _ind = 5;
else if(_dg <= 22.5 + 45. * 5.) _ind = 8;
else if(_dg <= 22.5 + 45. * 6.) _ind = 7;
else if(_dg <= 22.5 + 45. * 7.) _ind = 6;
else _ind = 3;
return filter[_ind] == 0;
}
void main() { #region
#region params
float bStr = borderStart.x;
@ -117,6 +136,7 @@ void main() { #region
base *= 2.;
}
if(angleFiltered(ang)) continue;
vec2 pxs = pixelPosition + vec2( cos(ang), sin(ang)) * i;
vec2 txs = pxs / dimension;
pxs = floor(pxs) + 0.5;
@ -143,6 +163,8 @@ void main() { #region
float tauDiv = TAU / 4.;
for(float j = 0.; j < 4.; j++) {
float ang = j * tauDiv;
if(angleFiltered(ang)) continue;
vec2 pxs = (pixelPosition + vec2( cos(ang), sin(ang)) ) / dimension;
if(side == 0 && crop_border == 1 && (pxs.x < 0. || pxs.x > 1. || pxs.y < 0. || pxs.y > 1.)) continue;