From a1fda8c6cdff9914c0af17efc5124ce6566a7b98 Mon Sep 17 00:00:00 2001 From: Brendan Hagan Date: Thu, 28 Jul 2022 00:18:28 -0400 Subject: [PATCH] feat: barebones image width/height script functions Ideally want a better way to make these properties or something. --- src/script/functions/image.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/script/functions/image.cpp b/src/script/functions/image.cpp index 1e147eb6..23fb8094 100644 --- a/src/script/functions/image.cpp +++ b/src/script/functions/image.cpp @@ -36,6 +36,18 @@ SCRIPT_FUNCTION(to_card_image) { } // ----------------------------------------------------------------------------- : Image functions + +SCRIPT_FUNCTION(width_of) { + SCRIPT_PARAM(GeneratedImageP, input); + Image image = input->generate(GeneratedImage::Options()); + SCRIPT_RETURN(image.GetWidth()); +} + +SCRIPT_FUNCTION(height_of) { + SCRIPT_PARAM(GeneratedImageP, input); + Image image = input->generate(GeneratedImage::Options()); + SCRIPT_RETURN(image.GetHeight()); +} SCRIPT_FUNCTION(linear_blend) { SCRIPT_PARAM(GeneratedImageP, image1); @@ -217,7 +229,9 @@ SCRIPT_FUNCTION(built_in_image) { void init_script_image_functions(Context& ctx) { ctx.setVariable(_("to_image"), script_to_image); - ctx.setVariable(_("to_card_image"), script_to_card_image); + ctx.setVariable(_("to_card_image"), script_to_card_image); + ctx.setVariable(_("width_of"), script_width_of); + ctx.setVariable(_("height_of"), script_height_of); ctx.setVariable(_("linear_blend"), script_linear_blend); ctx.setVariable(_("masked_blend"), script_masked_blend); ctx.setVariable(_("combine_blend"), script_combine_blend);