[Draw shape] Fix background color not applying.

This commit is contained in:
Tanasart 2024-11-08 09:08:54 +07:00
parent e37a2223b5
commit d84d96274a
2 changed files with 110 additions and 103 deletions

View file

@ -275,7 +275,6 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
var _color = _data[10]; var _color = _data[10];
var _df = _data[12]; var _df = _data[12];
var _path = _data[14]; var _path = _data[14];
var _bgC = _data[11];
var _bgcol = _bg? colToVec4(_data[11]) : [0, 0, 0, 0]; var _bgcol = _bg? colToVec4(_data[11]) : [0, 0, 0, 0];
var _posTyp = _data[15]; var _posTyp = _data[15];
@ -345,7 +344,7 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
inputs[15].setVisible(false); inputs[15].setVisible(false);
surface_set_target(_outSurf); surface_set_target(_outSurf);
if(_bg) draw_clear_alpha(0, 1); if(_bg) draw_clear_alpha(_data[11], 1);
else DRAW_CLEAR else DRAW_CLEAR
var segCount = _path.getSegmentCount(); var segCount = _path.getSegmentCount();

View file

@ -115,8 +115,6 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
inputs[ 2].setVisible(_font != ""); inputs[ 2].setVisible(_font != "");
inputs[ 3].setVisible(_font != ""); inputs[ 3].setVisible(_font != "");
inputs[11].setVisible(_font != "");
inputs[12].setVisible(_font != "");
} }
static waveGet = function(_ind) { static waveGet = function(_ind) {
@ -152,15 +150,17 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
} }
static processData = function(_outSurf, _data, _output_index, _array_index) { static processData = function(_outSurf, _data, _output_index, _array_index) {
var str = _data[0], strRaw = str; var str = _data[ 0];
var _font = _data[1]; var strRaw = str;
var _size = _data[2];
var _aa = _data[3]; var _font = _data[ 1];
var _col = _data[5]; var _size = _data[ 2];
var _dim = _data[6]; var _aa = _data[ 3];
var _hali = _data[7]; var _col = _data[ 5];
var _vali = _data[8]; var _dim = _data[ 6];
var _dim_type = _data[9]; var _hali = _data[ 7];
var _vali = _data[ 8];
var _dimt = _data[ 9];
var _padd = _data[10]; var _padd = _data[10];
var _trck = _data[11]; var _trck = _data[11];
var _line = _data[12]; var _line = _data[12];
@ -268,6 +268,7 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
for( var i = 0, n = array_length(_str_lines); i < n; i++ ) { for( var i = 0, n = array_length(_str_lines); i < n; i++ ) {
_max_ww = max(_max_ww, _line_widths[i]); _max_ww = max(_max_ww, _line_widths[i]);
_max_hh += string_height(_str_lines[i]); _max_hh += string_height(_str_lines[i]);
if(i) _max_hh += _line
} }
#endregion #endregion
@ -281,7 +282,7 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
var _use_path = _path != noone && struct_has(_path, "getPointDistance"); var _use_path = _path != noone && struct_has(_path, "getPointDistance");
var _ss = 1; var _ss = 1;
if(_use_path || _dim_type == 0) { if(_use_path || _dimt == 0) {
_sw = _dim[0]; _sw = _dim[0];
_sh = _dim[1]; _sh = _dim[1];
} else { } else {
@ -289,7 +290,7 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
_sh = hh; _sh = hh;
} }
if(_dim_type == 0 && !_use_path && _scaF) if(_dimt == 0 && !_use_path && _scaF)
_ss = min(_sw / ww, _sh / hh); _ss = min(_sw / ww, _sh / hh);
if(_wave) _sh += abs(_waveA) * 2; if(_wave) _sh += abs(_waveA) * 2;
@ -301,7 +302,7 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
#region position #region position
var tx = 0, ty = _padd[PADDING.top], _ty = 0; var tx = 0, ty = _padd[PADDING.top], _ty = 0;
if(_dim_type == 0) { if(_dimt == 0) {
switch(_vali) { switch(_vali) {
case 0 : ty = _padd[PADDING.top]; break; case 0 : ty = _padd[PADDING.top]; break;
case 1 : ty = (_sh - hh * _ss) / 2; break; case 1 : ty = (_sh - hh * _ss) / 2; break;
@ -326,42 +327,46 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
BLEND_ALPHA_MULP BLEND_ALPHA_MULP
} }
for( var i = 0, n = array_length(_str_lines); i < n; i++ ) { #region draw __temp_pt = _path;
var _str_line = _str_lines[i]; __temp_ss = _ss;
var _line_width = _line_widths[i]; __temp_trck = _trck;
if(_use_path) { if(_use_path) {
draw_set_text(font, fa_left, fa_bottom, _col); var _pthl = _path.getLength(0), va;
tx = _pthS;
ty = 0;
switch(_hali) {
case 0 : tx = _pthS; break;
case 1 : tx = _pthS - _line_width / 2; break;
case 2 : tx = _line_width - _pthS; break;
}
switch(_vali) { switch(_vali) {
case 0 : ty = _ty; break; case 0 : ty = 0; va = fa_top; break;
case 1 : ty = -hh / 2 + _ty; break; case 1 : ty = (_max_hh - line_get_height(font)) / 2; va = fa_center; break;
case 2 : ty = -hh + _ty; break; case 2 : ty = _max_hh; va = fa_top; break;
} }
__temp_tx = tx; for( var i = 0, n = array_length(_str_lines); i < n; i++ ) {
var _str_line = _str_lines[i];
var _line_width = _line_widths[i];
draw_set_text(font, fa_left, va, _col);
switch(_hali) {
case 0 : tx = 0; break;
case 1 : tx = _pthl / 2 - _line_width / 2; break;
case 2 : tx = _pthl - _line_width; break;
}
__temp_tx = tx + _pthS;
__temp_ty = ty; __temp_ty = ty;
__temp_pt = _path; __temp_p0 = new __vec2();
__temp_p1 = new __vec2();
string_foreach(_str_line, function(_chr, _ind) { string_foreach(_str_line, function(_chr, _ind) {
var _pos = __temp_pt.getPointDistance(__temp_tx); var _p1 = __temp_pt.getPointDistance(__temp_tx, 0, __temp_p0);
var _p2 = __temp_pt.getPointDistance(__temp_tx + 0.1); var _p2 = __temp_pt.getPointDistance(__temp_tx + .1, 0, __temp_p1);
var _nor = point_direction(_pos.x, _pos.y, _p2.x, _p2.y); var _nor = point_direction(_p1.x, _p1.y, _p2.x, _p2.y);
var _line_ang = _nor - 90; var _line_ang = _nor + 90;
var _dx = lengthdir_x(__temp_ty, _line_ang); var _dx = lengthdir_x(__temp_ty, _line_ang);
var _dy = lengthdir_y(__temp_ty, _line_ang); var _dy = lengthdir_y(__temp_ty, _line_ang);
var _tx = _pos.x + _dx; var _tx = _p1.x + _dx;
var _ty = _pos.y + _dy; var _ty = _p1.y + _dy;
if(__wave) { if(__wave) {
var _wd = waveGet(_ind); var _wd = waveGet(_ind);
@ -373,12 +378,17 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
__temp_tx += string_width(_chr) + __temp_trck; __temp_tx += string_width(_chr) + __temp_trck;
}); });
_ty += string_height("l") + _line; ty -= string_height(_str_line) + _line;
}
} else { } else {
for( var i = 0, n = array_length(_str_lines); i < n; i++ ) {
var _str_line = _str_lines[i];
var _line_width = _line_widths[i];
draw_set_text(font, fa_left, fa_top, _col); draw_set_text(font, fa_left, fa_top, _col);
tx = _padd[PADDING.left]; tx = _padd[PADDING.left];
if(_dim_type == 0) if(_dimt == 0)
switch(_hali) { switch(_hali) {
case 0 : tx = _padd[PADDING.left]; break; case 0 : tx = _padd[PADDING.left]; break;
case 1 : tx = (_sw - _line_width * _ss) / 2; break; case 1 : tx = (_sw - _line_width * _ss) / 2; break;
@ -387,8 +397,6 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
__temp_tx = tx; __temp_tx = tx;
__temp_ty = ty; __temp_ty = ty;
__temp_ss = _ss;
__temp_trck = _trck;
string_foreach(_str_line, function(_chr, _ind) { string_foreach(_str_line, function(_chr, _ind) {
var _tx = __temp_tx; var _tx = __temp_tx;
@ -403,9 +411,9 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
__temp_tx += (string_width(_chr) + __temp_trck) * __temp_ss; __temp_tx += (string_width(_chr) + __temp_trck) * __temp_ss;
}); });
ty += (string_height("l") + _line) * _ss; ty += (string_height(_str_line) + _line) * _ss;
}
} }
} #endregion
surface_reset_shader(); surface_reset_shader();
return _outSurf; return _outSurf;