Add canvas UI node

This commit is contained in:
ShadelessFox
2025-01-19 14:11:56 +01:00
parent cb960ceaad
commit ee31f401aa
12 changed files with 279 additions and 2 deletions
+19
View File
@@ -0,0 +1,19 @@
#include "Canvas.hpp"
#include "graphics/core/Batch2D.hpp"
#include "graphics/core/DrawContext.hpp"
#include "graphics/core/Texture.hpp"
gui::Canvas::Canvas(ImageFormat inFormat, glm::uvec2 inSize) : UINode(inSize) {
ImageData data {inFormat, inSize.x, inSize.y};
mTexture = Texture::from(&data);
}
void gui::Canvas::draw(const DrawContext& pctx, const Assets& assets) {
auto pos = calcPos();
auto col = calcColor();
auto batch = pctx.getBatch2D();
batch->texture(mTexture.get());
batch->rect(pos.x, pos.y, size.x, size.y, 0, 0, 0, {}, false, true, col);
}