cc-haxe/src/lib/ui/elements/TextElement.hx

37 lines
696 B
Haxe
Raw Normal View History

2023-02-05 01:56:04 +00:00
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;
}
2023-07-08 12:01:38 +00:00
public function render(bounds: Pos):Canvas {
2023-02-05 01:56:04 +00:00
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;
}
}