Undertale script viewer

← back to main script listing

gml_Script_scr_drawtext_centered_scaled

(view raw script w/o annotations or w/e)
1
var xx = argument0;
2
var yy = argument1;
3
var text = argument2;
4
var xscale = argument3;
5
var yscale = argument4;
6
var display_scale = surface_get_width(application_surface) / view_wview[view_current];
7
var lineheight = round(string_height(" ") * yscale);
8
var eol = string_pos("#", text);
9
yy = round(yy * display_scale) / display_scale;
10
while (eol != 0)
11
{
12
    var line = substr(text, 1, eol);
13
    text = substr(text, eol + 1);
14
    width = string_width(line) * xscale;
15
    var line_x = round((xx - (width / 2)) * display_scale) / display_scale;
16
    draw_text_transformed(line_x, yy, line, xscale, yscale, 0);
17
    yy += lineheight;
18
    eol = string_pos("#", text);
19
}
20
var width = string_width(text) * xscale;
21
draw_text_transformed(round(xx - (width / 2)), yy, text, xscale, yscale, 0);