From 63239fa51a3c2319f56fd3ec9f307a5ad84bf6dc Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Tue, 16 Jul 2024 20:34:09 -0500 Subject: [PATCH] mum image fix --- scripts/mum.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/scripts/mum.js b/scripts/mum.js index 283da0d..33c1073 100644 --- a/scripts/mum.js +++ b/scripts/mum.js @@ -190,18 +190,30 @@ mum.image = function(path, data = {}) if (typeof path === 'string') tex = game.texture(path); - data.width ??= tex.width; - data.height ??= tex.height; + if (!data.height) + if (data.width) + data.height = tex.height * (data.width/tex.width); + else + data.height = tex.height; - var aa = [0,0].sub(data.anchor); + if (!data.width) + if (data.height) + data.width = tex.width * (data.height/tex.height); + else + data.height = tex.height; + + + + if (!data.width) data.width = tex.width; + if (!data.height) data.height = tex.height; + + var aa = [0,1].sub(data.anchor); data.drawpos = data.drawpos.add(aa.scale([data.width,data.height])); if (data.slice) render.slice9(tex, data.drawpos, data.slice, [data.width,data.height]); - else { - cursor.y -= tex.height*data.scale; - data.bb = render.image(tex, data.drawpos, [data.scale*tex.width, data.scale*tex.height]); - } + else + data.bb = render.image(tex, data.drawpos, [data.width, data.height]); end(data); }