mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-24 14:06:23 +01:00
[Blur] Add fractional unit to strength.
This commit is contained in:
parent
31e13b15f4
commit
39e002eae3
5 changed files with 32 additions and 14 deletions
|
@ -2,8 +2,10 @@ function Node_Blur(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
name = "Blur";
|
||||
|
||||
newInput(0, nodeValue_Surface("Surface in", self));
|
||||
|
||||
newInput(1, nodeValue_Int("Size", self, 3))
|
||||
.setDisplay(VALUE_DISPLAY.slider, { range: [ 1, 32, 0.1 ] });
|
||||
.setValidator(VV_min(0))
|
||||
.setUnitRef(function(index) /*=>*/ {return getDimension(index)});
|
||||
|
||||
newInput(2, nodeValue_Enum_Scroll("Oversample mode", self, 0, [ "Empty", "Clamp", "Repeat" ]))
|
||||
.setTooltip("How to deal with pixel outside the surface.\n - Empty: Use empty pixel\n - Clamp: Repeat edge pixel\n - Repeat: Repeat texture.");
|
||||
|
@ -45,11 +47,11 @@ function Node_Blur(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
attribute_oversample();
|
||||
surface_blur_init();
|
||||
|
||||
static step = function() { #region
|
||||
static step = function() {
|
||||
__step_mask_modifier();
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
|
||||
static processData = function(_outSurf, _data, _output_index, _array_index) {
|
||||
var _surf = _data[0];
|
||||
var _size = min(128, _data[1]);
|
||||
var _clamp = struct_try_get(attributes, "oversample");
|
||||
|
@ -121,5 +123,5 @@ function Node_Blur(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
_outSurf = channel_apply(_data[0], _outSurf, _data[8]);
|
||||
|
||||
return _outSurf;
|
||||
} #endregion
|
||||
}
|
||||
}
|
|
@ -334,9 +334,6 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
if(editWidget) {
|
||||
editWidget.unit = unit;
|
||||
editWidget.onSurfaceSize = ref;
|
||||
|
||||
if(is_instanceof(editWidget, textBox))
|
||||
editWidget.side_button = unit.triggerButton;
|
||||
}
|
||||
|
||||
unit.reference = ref;
|
||||
|
|
|
@ -4,6 +4,12 @@ function __NodeValue_Int(_name, _node, _value, _tooltip = "") : NodeValue(_name,
|
|||
|
||||
/////============== GET =============
|
||||
|
||||
static valueProcess = function(value, nodeFrom = undefined, applyUnit = true, arrIndex = 0) {
|
||||
if(validator != noone) value = validator.validate(value);
|
||||
value = applyUnit? unit.apply(value, arrIndex) : value;
|
||||
return round(value);
|
||||
}
|
||||
|
||||
static getValue = function(_time = CURRENT_FRAME, applyUnit = true, arrIndex = 0, useCache = false, log = false) { //// Get value
|
||||
getValueRecursive(self.__curr_get_val, _time);
|
||||
var val = __curr_get_val[0];
|
||||
|
@ -14,9 +20,7 @@ function __NodeValue_Int(_name, _node, _value, _tooltip = "") : NodeValue(_name,
|
|||
|
||||
if(typ != VALUE_TYPE.surface) {
|
||||
if(typ == VALUE_TYPE.text) val = toNumber(val);
|
||||
if(validator != noone) val = validator.validate(val);
|
||||
|
||||
return val;
|
||||
return valueProcess(val, nod, applyUnit);
|
||||
}
|
||||
|
||||
// Dimension conversion
|
||||
|
@ -39,8 +43,10 @@ function __NodeValue_Int(_name, _node, _value, _tooltip = "") : NodeValue(_name,
|
|||
|
||||
if(eqSize) return _osZ;
|
||||
return sArr;
|
||||
|
||||
} else if (is_surface(val))
|
||||
return [ surface_get_width_safe(val), surface_get_height_safe(val) ];
|
||||
|
||||
return [ 1, 1 ];
|
||||
}
|
||||
|
||||
|
|
|
@ -503,6 +503,7 @@ function nodeValueUnit(_nodeValue) constructor {
|
|||
_nodeValue.unitConvert(mode);
|
||||
_nodeValue.node.doUpdate();
|
||||
});
|
||||
|
||||
triggerButton.icon_blend = COLORS._main_icon_light;
|
||||
triggerButton.icon = THEME.unit_ref;
|
||||
triggerButton.tooltip = new tooltipSelector("Unit", ["Pixel", "Fraction"]);
|
||||
|
@ -520,7 +521,6 @@ function nodeValueUnit(_nodeValue) constructor {
|
|||
static draw = function(_x, _y, _w, _h, _m) {
|
||||
triggerButton.icon_index = mode;
|
||||
triggerButton.tooltip.index = mode;
|
||||
|
||||
triggerButton.draw(_x, _y, _w, _h, _m, THEME.button_hide);
|
||||
}
|
||||
|
||||
|
@ -555,8 +555,9 @@ function nodeValueUnit(_nodeValue) constructor {
|
|||
for( var i = 0, n = array_length(value); i < n; i++ )
|
||||
_val[i] = value[i] * base;
|
||||
return _val;
|
||||
}
|
||||
|
||||
} else if(is_array(value)) {
|
||||
if(is_array(value)) {
|
||||
if(inv) {
|
||||
base = [
|
||||
base[0] == 0? 0 : 1 / array_safe_get(base, 0),
|
||||
|
@ -598,6 +599,11 @@ function nodeValueUnit(_nodeValue) constructor {
|
|||
|
||||
return _val;
|
||||
}
|
||||
|
||||
} else {
|
||||
base = array_safe_get(base, 0, 1);
|
||||
if(inv) base = base == 0? 0 : 1 / base;
|
||||
return value * base;
|
||||
}
|
||||
|
||||
return value;
|
||||
|
|
|
@ -13,6 +13,7 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor {
|
|||
precision = 5;
|
||||
padding = ui(8);
|
||||
|
||||
unit = noone;
|
||||
suffix = "";
|
||||
|
||||
no_empty = true;
|
||||
|
@ -473,6 +474,12 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor {
|
|||
_w -= _bs + ui(4);
|
||||
}
|
||||
|
||||
if(unit != noone && unit.reference != noone) {
|
||||
unit.triggerButton.setFocusHover(iactive, ihover);
|
||||
unit.draw(_x + _w - _bs, _y + _h / 2 - _bs / 2, _bs, _bs, _m);
|
||||
_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);
|
||||
|
|
Loading…
Reference in a new issue