mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 22:46:19 +01:00
Fix some node draw string extremely small.
This commit is contained in:
parent
99315c5872
commit
a7d56baffa
10 changed files with 48 additions and 50 deletions
|
@ -21,3 +21,10 @@ function draw_text_ext_add(_x, _y, _text, _sep, _w) {
|
||||||
draw_text_ext(_x, _y, _text, _sep, _w);
|
draw_text_ext(_x, _y, _text, _sep, _w);
|
||||||
BLEND_NORMAL;
|
BLEND_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function draw_text_bbox(bbox, text) {
|
||||||
|
var ss = min(bbox.w / string_width(text), bbox.h / string_height(text));
|
||||||
|
ss = max(0.5, ss);
|
||||||
|
|
||||||
|
draw_text_cut(bbox.xc, bbox.yc, text, bbox.w, ss);
|
||||||
|
}
|
|
@ -12,10 +12,10 @@ function Node_String(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
|
||||||
}
|
}
|
||||||
|
|
||||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
||||||
draw_set_text(f_h5, fa_center, fa_center, COLORS._main_text);
|
|
||||||
var str = inputs[| 0].getValue();
|
var str = inputs[| 0].getValue();
|
||||||
var bbox = drawGetBbox(xx, yy, _s);
|
var bbox = drawGetBbox(xx, yy, _s);
|
||||||
var ss = string_scale(str, bbox.w, bbox.h);
|
|
||||||
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
|
draw_set_text(f_h5, fa_center, fa_center, COLORS._main_text);
|
||||||
|
draw_text_bbox(bbox, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,10 +17,10 @@ function Node_String_Get_Char(_x, _y, _group = noone) : Node_Processor(_x, _y, _
|
||||||
}
|
}
|
||||||
|
|
||||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
||||||
draw_set_text(f_h5, fa_center, fa_center, COLORS._main_text);
|
|
||||||
var str = inputs[| 0].getValue();
|
var str = inputs[| 0].getValue();
|
||||||
var bbox = drawGetBbox(xx, yy, _s);
|
var bbox = drawGetBbox(xx, yy, _s);
|
||||||
var ss = string_scale(str, bbox.w, bbox.h);
|
|
||||||
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
|
draw_set_text(f_h5, fa_center, fa_center, COLORS._main_text);
|
||||||
|
draw_text_bbox(bbox, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -25,10 +25,10 @@ function Node_String_Join(_x, _y, _group = noone) : Node(_x, _y, _group) constru
|
||||||
}
|
}
|
||||||
|
|
||||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
||||||
draw_set_text(f_h5, fa_center, fa_center, COLORS._main_text);
|
|
||||||
var str = outputs[| 0].getValue();
|
var str = outputs[| 0].getValue();
|
||||||
var bbox = drawGetBbox(xx, yy, _s);
|
var bbox = drawGetBbox(xx, yy, _s);
|
||||||
var ss = string_scale(str, bbox.w, bbox.h);
|
|
||||||
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
|
draw_set_text(f_h5, fa_center, fa_center, COLORS._main_text);
|
||||||
|
draw_text_bbox(bbox, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -20,10 +20,10 @@ function Node_String_Length(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
||||||
}
|
}
|
||||||
|
|
||||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
||||||
draw_set_text(f_h5, fa_center, fa_center, COLORS._main_text);
|
|
||||||
var str = outputs[| 0].getValue();
|
var str = outputs[| 0].getValue();
|
||||||
var bbox = drawGetBbox(xx, yy, _s);
|
var bbox = drawGetBbox(xx, yy, _s);
|
||||||
var ss = string_scale(str, bbox.w, bbox.h);
|
|
||||||
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
|
draw_set_text(f_h5, fa_center, fa_center, COLORS._main_text);
|
||||||
|
draw_text_bbox(bbox, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,10 +15,10 @@ function Node_String_Merge(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
||||||
}
|
}
|
||||||
|
|
||||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
||||||
draw_set_text(f_h5, fa_center, fa_center, COLORS._main_text);
|
|
||||||
var str = inputs[| 0].getValue();
|
var str = inputs[| 0].getValue();
|
||||||
var bbox = drawGetBbox(xx, yy, _s);
|
var bbox = drawGetBbox(xx, yy, _s);
|
||||||
var ss = string_scale(str, bbox.w, bbox.h);
|
|
||||||
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
|
draw_set_text(f_h5, fa_center, fa_center, COLORS._main_text);
|
||||||
|
draw_text_bbox(bbox, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -27,13 +27,9 @@ function Node_String_Regex_Search(_x, _y, _group = noone) : Node_Processor(_x, _
|
||||||
|
|
||||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
||||||
var str = outputs[| 0].getValue();
|
var str = outputs[| 0].getValue();
|
||||||
|
var bbox = drawGetBbox(xx, yy, _s);
|
||||||
if(is_array(str) && array_length(str))
|
|
||||||
str = str[0];
|
|
||||||
|
|
||||||
draw_set_text(f_h5, fa_center, fa_center, COLORS._main_text);
|
draw_set_text(f_h5, fa_center, fa_center, COLORS._main_text);
|
||||||
var bbox = drawGetBbox(xx, yy, _s);
|
draw_text_bbox(bbox, str);
|
||||||
var ss = string_scale(str, bbox.w, bbox.h);
|
|
||||||
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -69,15 +69,9 @@ function Node_String_Trim(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
||||||
|
|
||||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
||||||
var str = outputs[| 0].getValue();
|
var str = outputs[| 0].getValue();
|
||||||
var hed = inputs[| 1].getValue();
|
var bbox = drawGetBbox(xx, yy, _s);
|
||||||
var tal = inputs[| 2].getValue();
|
|
||||||
|
|
||||||
if(is_array(str) && array_length(str))
|
|
||||||
str = str[0];
|
|
||||||
|
|
||||||
draw_set_text(f_h5, fa_center, fa_center, COLORS._main_text);
|
draw_set_text(f_h5, fa_center, fa_center, COLORS._main_text);
|
||||||
var bbox = drawGetBbox(xx, yy, _s);
|
draw_text_bbox(bbox, str);
|
||||||
var ss = string_scale(str, bbox.w, bbox.h);
|
|
||||||
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,22 +6,23 @@ function string_cut(str, w, tail = "...", scale = 1) {
|
||||||
var ww = 0;
|
var ww = 0;
|
||||||
var ind = 1;
|
var ind = 1;
|
||||||
var ss = "";
|
var ss = "";
|
||||||
var tw = string_width(tail);
|
var _str = str;
|
||||||
|
var tw = string_width(tail) * scale;
|
||||||
if(string_width(str) <= w) return str;
|
if(string_width(str) <= w) return str;
|
||||||
|
|
||||||
while(ind <= string_length(str)) {
|
var amo = string_length(str);
|
||||||
var ch = string_char_at(str, ind);
|
for( var i = 1; i <= amo; i++ ) {
|
||||||
|
var ch = string_char_at(str, 1);
|
||||||
|
str = string_copy(str, 2, string_length(str) - 1);
|
||||||
|
|
||||||
var _w = string_width(ch) * scale;
|
var _w = string_width(ch) * scale;
|
||||||
|
|
||||||
if(ww + _w + tw >= w) {
|
|
||||||
ss += tail;
|
|
||||||
break;
|
|
||||||
} else
|
|
||||||
ss += ch;
|
|
||||||
|
|
||||||
ww += _w;
|
ww += _w;
|
||||||
|
|
||||||
ind++;
|
var _tl = string_width(str) * scale;
|
||||||
|
|
||||||
|
if(ww + tw > w)
|
||||||
|
return ww + _tl <= w? _str : ss + tail;
|
||||||
|
ss += ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ss;
|
return ss;
|
||||||
|
|
Loading…
Reference in a new issue