Pixel-Composer/scripts/draw_fit/draw_fit.gml

19 lines
892 B
Text
Raw Normal View History

2023-03-28 06:58:28 +02:00
function draw_sprite_fit(spr, ind, xx, yy, w, h, color = c_white, alpha = 1) {
2023-01-25 06:49:00 +01:00
var ss = min(w / sprite_get_width(spr), h / sprite_get_height(spr));
2023-03-28 06:58:28 +02:00
draw_sprite_ext(spr, ind, xx, yy, ss, ss, 0, color, alpha);
2023-01-25 06:49:00 +01:00
}
2023-05-22 20:31:55 +02:00
function draw_surface_fit(surf, xx, yy, w, h, color = c_white, alpha = 1) {
2023-09-08 21:37:36 +02:00
var ss = min(w / surface_get_width_safe(surf), h / surface_get_height_safe(surf));
draw_surface_ext_safe(surf, xx - surface_get_width_safe(surf) * ss / 2, yy - surface_get_height_safe(surf) * ss / 2, ss, ss,, color, alpha);
2023-01-25 06:49:00 +01:00
}
2023-10-06 11:51:11 +02:00
function draw_surface_stretch_fit(surf, xx, yy, w, h, sw = 1, sh = 1) {
2023-01-25 06:49:00 +01:00
var ss = min(w / sw, h / sh);
draw_surface_stretched_safe(surf, xx - sw * ss / 2, yy - sh * ss / 2, sw * ss, sh * ss);
2023-05-22 20:31:55 +02:00
}
function draw_surface_bbox(surf, bbox, color = c_white, alpha = 1) {
if(!surface_exists(surf)) return;
2023-05-22 20:31:55 +02:00
draw_surface_fit(surf, bbox.xc, bbox.yc, bbox.w, bbox.h, color, alpha);
2023-01-25 06:49:00 +01:00
}