aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic-extension/utility/Utilities.cpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-12-26 00:00:02 +0100
committer GitHub <noreply@github.com>2023-12-26 00:00:02 +0100
commitd114ecaa5a54f1e8e20828561a3cd26a09dc10a3 (patch)
treea59c5b960a706a383b8ebd1dbcfb704067a5b51b /extension/src/openvic-extension/utility/Utilities.cpp
parentd26c990d9a5596a3ef3b32ba1cb0f99950cd6d34 (diff)
parent4e9764ee29fb7b453862835d5aa3a081b0f9a269 (diff)
Merge pull request #179 from OpenVicProject/ui-work
GUIOverlappingElementsBox + GUINode improvements
Diffstat (limited to 'extension/src/openvic-extension/utility/Utilities.cpp')
-rw-r--r--extension/src/openvic-extension/utility/Utilities.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/extension/src/openvic-extension/utility/Utilities.cpp b/extension/src/openvic-extension/utility/Utilities.cpp
index 099b5a9..8293e70 100644
--- a/extension/src/openvic-extension/utility/Utilities.cpp
+++ b/extension/src/openvic-extension/utility/Utilities.cpp
@@ -122,3 +122,18 @@ Ref<FontFile> Utilities::load_godot_font(String const& fnt_path, Ref<Image> cons
}
return font;
}
+
+Ref<Image> Utilities::make_solid_colour_image(Color const& colour, int32_t width, int32_t height, Image::Format format) {
+ const Ref<Image> result = Image::create(width, height, false, format);
+ ERR_FAIL_NULL_V(result, nullptr);
+ result->fill(colour);
+ return result;
+}
+
+Ref<ImageTexture> Utilities::make_solid_colour_texture(Color const& colour, int32_t width, int32_t height, Image::Format format) {
+ const Ref<Image> image = make_solid_colour_image(colour, width, height, format);
+ ERR_FAIL_NULL_V(image, nullptr);
+ const Ref<ImageTexture> result = ImageTexture::create_from_image(image);
+ ERR_FAIL_NULL_V(result, nullptr);
+ return result;
+}