Deltarune script viewer

← back to main script listing

gml_GlobalScript_scr_draw_sprite_crop

(view raw script w/o annotations or w/e)
1
function scr_draw_sprite_crop
scr_draw_sprite_crop

function scr_draw_sprite_crop(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) { var _sprite_xoffset = sprite_get_xoffset(arg0); var _sprite_yoffset = sprite_get_yoffset(arg0); var _sprite_width = sprite_get_width(arg0); var _sprite_height = sprite_get_height(arg0); var _true_xanchor = x - abs(sprite_xoffset); var _true_yanchor = y - abs(sprite_yoffset); if (_true_xanchor > arg2 && (_true_xanchor + _sprite_width) < arg4 && _true_yanchor > arg3 && (_true_yanchor + _sprite_height) < arg5) { draw_self(); exit; } var _leftcrop = clamp(arg2 - _true_xanchor, 0, abs(_sprite_width)); var _topcrop = clamp(arg3 - _true_yanchor, 0, abs(_sprite_height)); var _rightcrop = clamp(arg4 - _true_xanchor, 0, abs(_sprite_width)); var _bottomcrop = clamp(arg5 - _true_yanchor, 0, abs(_sprite_height)); draw_sprite_part(arg0, arg1, _leftcrop, _topcrop, _rightcrop, _bottomcrop, (arg6 - _sprite_xoffset) + _leftcrop, (arg7 - _sprite_yoffset) + _topcrop); }
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
2
{
3
    var _sprite_xoffset = sprite_get_xoffset(arg0);
4
    var _sprite_yoffset = sprite_get_yoffset(arg0);
5
    var _sprite_width = sprite_get_width(arg0);
6
    var _sprite_height = sprite_get_height(arg0);
7
    var _true_xanchor = x - abs(sprite_xoffset);
8
    var _true_yanchor = y - abs(sprite_yoffset);
9
    if (_true_xanchor > arg2 && (_true_xanchor + _sprite_width) < arg4 && _true_yanchor > arg3 && (_true_yanchor + _sprite_height) < arg5)
10
    {
11
        draw_self();
12
        exit;
13
    }
14
    var _leftcrop = clamp(arg2 - _true_xanchor, 0, abs(_sprite_width));
15
    var _topcrop = clamp(arg3 - _true_yanchor, 0, abs(_sprite_height));
16
    var _rightcrop = clamp(arg4 - _true_xanchor, 0, abs(_sprite_width));
17
    var _bottomcrop = clamp(arg5 - _true_yanchor, 0, abs(_sprite_height));
18
    draw_sprite_part(arg0, arg1, _leftcrop, _topcrop, _rightcrop, _bottomcrop, (arg6 - _sprite_xoffset) + _leftcrop, (arg7 - _sprite_yoffset) + _topcrop);
19
}