added styles to TextElement
This commit is contained in:
@@ -6,10 +6,12 @@ class TextElement implements UIElement {
|
||||
public var text:String;
|
||||
|
||||
private final uiEvents:UIEvents;
|
||||
private final style:Style;
|
||||
|
||||
public function new(text:String, ?uiEvents:UIEvents) {
|
||||
public function new(text:String, ?props: {?style:Style, ?uiEvents:UIEvents}) {
|
||||
this.text = text;
|
||||
this.uiEvents = uiEvents;
|
||||
this.uiEvents = props?.uiEvents;
|
||||
this.style = props?.style ?? {fgColor: White, bgColor: Black};
|
||||
}
|
||||
|
||||
public function set(text:String) {
|
||||
@@ -28,7 +30,7 @@ class TextElement implements UIElement {
|
||||
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});
|
||||
canvas.set({x: i, y: 0}, {bg: style.bgColor ?? Black, textColor: style.fgColor ?? White, char: c});
|
||||
}
|
||||
|
||||
return canvas;
|
||||
|
||||
Reference in New Issue
Block a user