diff --git a/src/lib/ui/Canvas.hx b/src/lib/ui/Canvas.hx index 4063bb4..67e5396 100644 --- a/src/lib/ui/Canvas.hx +++ b/src/lib/ui/Canvas.hx @@ -1,5 +1,6 @@ package lib.ui; +import kernel.ui.WindowContext; import lib.Pos; import lib.Rect; import kernel.ui.Pixel; @@ -67,6 +68,28 @@ abstract Canvas(Array>) to Array> from Array line in this) { + if (line == null || line.length == 0) { + continue; + } + + for (pixelIndex => pixel in line) { + if (pixel == null) { + continue; + } + + ctx.setCursorPos(pixelIndex, lineIndex); + ctx.setBackgroundColor(pixel.bg); + ctx.setTextColor(pixel.textColor); + ctx.write(pixel.char); + } + } + } } class CanvasKeyValueIterator {