something something ui
This commit is contained in:
36
src/lib/ui/elements/TextElement.hx
Normal file
36
src/lib/ui/elements/TextElement.hx
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user