Added pixel texture element

This commit is contained in:
2026-06-04 23:46:34 +01:00
parent 55241b9c93
commit e7418fde08
9 changed files with 567 additions and 30 deletions
+32 -2
View File
@@ -8,7 +8,8 @@
enum Type { IMAGE,
TEXT,
RECT };
RECT,
SCRIPT };
enum ClickMode { PASS,
BLOCK,
@@ -72,8 +73,9 @@ private:
};
struct ERect : Element {
Vec2<float> shape = {0, 0};
Color color = {255, 255, 255};
Vec2<float> shape = {0, 0};
Vec2<float> size() override;
ERect(Vec2<float> shape, Color color) : Element(Type::RECT), shape(shape), color(color) {}
@@ -81,6 +83,34 @@ struct ERect : Element {
void render(uint64_t) override;
};
struct EScript : Element {
Ruby::Block script;
uint64_t scripted_id = UINT64_MAX;
bool pixel_art = false;
Vec2<float> shape;
EScript(Vec2<float> shape) : Element(Type::SCRIPT), shape(shape) {
scripted_id = window.create_scripted(shape, pixel_art);
}
~EScript() {
if (scripted_id != UINT64_MAX)
scripted_pool.release(scripted_id);
};
Vec2<float> size() override {
return shape;
}
bool update_scripted(Rect content_rect, const char *new_content, uint32_t length) {
return window.update_scripted(scripted_id, content_rect, new_content, length);
}
void render(uint64_t) override {
window.draw_scripted(scripted_id, position, z, rotation, pivot, scale, alpha);
};
};
inline Pool<Element> element_pool;
} // namespace app