mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-11-14 22:43:53 +01:00
[Crop content] Add cropped distance output.
This commit is contained in:
parent
92c1ac3979
commit
1e8a0eeab0
@ -14,6 +14,9 @@ function Node_Crop_Content(_x, _y, _group = noone) : Node(_x, _y, _group) constr
|
|||||||
|
|
||||||
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
|
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
|
||||||
|
|
||||||
|
newOutput(1, nodeValue_Output("Crop distance", self, VALUE_TYPE.integer, [ 0, 0, 0, 0 ]))
|
||||||
|
.setDisplay(VALUE_DISPLAY.padding);
|
||||||
|
|
||||||
input_display_list = [ 1,
|
input_display_list = [ 1,
|
||||||
["Surfaces", false], 0, 2, 4,
|
["Surfaces", false], 0, 2, 4,
|
||||||
["Padding", false], 3,
|
["Padding", false], 3,
|
||||||
@ -108,7 +111,8 @@ function Node_Crop_Content(_x, _y, _group = noone) : Node(_x, _y, _group) constr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var res = [];
|
var res = [];
|
||||||
|
var crop = [];
|
||||||
|
|
||||||
for( var i = 0, n = _amo; i < n; i++ ) {
|
for( var i = 0, n = _amo; i < n; i++ ) {
|
||||||
var _surf = _inSurf[i];
|
var _surf = _inSurf[i];
|
||||||
@ -118,7 +122,8 @@ function Node_Crop_Content(_x, _y, _group = noone) : Node(_x, _y, _group) constr
|
|||||||
resDim[DIMENSION.width] += _padd[PADDING.left] + _padd[PADDING.right];
|
resDim[DIMENSION.width] += _padd[PADDING.left] + _padd[PADDING.right];
|
||||||
resDim[DIMENSION.height] += _padd[PADDING.top] + _padd[PADDING.bottom];
|
resDim[DIMENSION.height] += _padd[PADDING.top] + _padd[PADDING.bottom];
|
||||||
|
|
||||||
res[i] = surface_create_valid(resDim[DIMENSION.width], resDim[DIMENSION.height], cDep);
|
res[i] = surface_create_valid(resDim[DIMENSION.width], resDim[DIMENSION.height], cDep);
|
||||||
|
crop[i] = [ surface_get_width_safe(_surf) - maxx - 1, miny, minx, surface_get_height_safe(_surf) - maxy - 1 ];
|
||||||
|
|
||||||
surface_set_shader(res[i], noone);
|
surface_set_shader(res[i], noone);
|
||||||
draw_surface_safe(_surf, -minx + _padd[PADDING.left], -miny + _padd[PADDING.top]);
|
draw_surface_safe(_surf, -minx + _padd[PADDING.left], -miny + _padd[PADDING.top]);
|
||||||
@ -130,6 +135,7 @@ function Node_Crop_Content(_x, _y, _group = noone) : Node(_x, _y, _group) constr
|
|||||||
resDim[DIMENSION.height] += _padd[PADDING.top] + _padd[PADDING.bottom];
|
resDim[DIMENSION.height] += _padd[PADDING.top] + _padd[PADDING.bottom];
|
||||||
|
|
||||||
res[i] = surface_create_valid(resDim[DIMENSION.width], resDim[DIMENSION.height], cDep);
|
res[i] = surface_create_valid(resDim[DIMENSION.width], resDim[DIMENSION.height], cDep);
|
||||||
|
crop[i] = [ surface_get_width_safe(_surf) - maxx - 1, miny, minx, surface_get_height_safe(_surf) - maxy - 1 ];
|
||||||
|
|
||||||
surface_set_shader(res[i], noone);
|
surface_set_shader(res[i], noone);
|
||||||
draw_surface_safe(_surf, -minx[i] + _padd[PADDING.left], -miny[i] + _padd[PADDING.top]);
|
draw_surface_safe(_surf, -minx[i] + _padd[PADDING.left], -miny[i] + _padd[PADDING.top]);
|
||||||
@ -137,7 +143,12 @@ function Node_Crop_Content(_x, _y, _group = noone) : Node(_x, _y, _group) constr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!_arr) res = res[0];
|
if(!_arr) {
|
||||||
|
res = res[0];
|
||||||
|
crop = crop[0];
|
||||||
|
}
|
||||||
|
|
||||||
outputs[0].setValue(res);
|
outputs[0].setValue(res);
|
||||||
|
outputs[1].setValue(crop);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user