something something ui

This commit is contained in:
2023-02-05 02:56:04 +01:00
parent 3e7d993662
commit a4e4e103bd
8 changed files with 197 additions and 19 deletions

View File

@@ -0,0 +1,36 @@
package lib.ui.elements;
import lib.ui.elements.UIElement;
class TextElement implements UIElement {
public var text:String;
private final uiEvents:UIEvents;
public function new(text:String, ?uiEvents:UIEvents) {
this.text = text;
this.uiEvents = uiEvents;
}
public function set(text:String) {
this.text = text;
}
public function get():String {
return this.text;
}
public function getEventHandlers():UIEvents {
return uiEvents;
}
public function render():Canvas {
var canvas = new Canvas();
for (i in 0...this.text.length) {
var c = this.text.charAt(i);
canvas.set({x: i, y: 0}, {bg: Black, textColor: White, char: c});
}
return canvas;
}
}