From ec7535ccb63ba24f34b426e8e749234e6a3c0454 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Sun, 1 May 2022 01:02:03 +0200 Subject: [PATCH] added canvas debug print --- src/util/Debug.hx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/util/Debug.hx b/src/util/Debug.hx index 5301f2f..4a1f905 100644 --- a/src/util/Debug.hx +++ b/src/util/Debug.hx @@ -18,6 +18,24 @@ class Debug { Log.debug("CC/MC version:" + ComputerCraft._HOST); } + public static function printCanvasToConsole(canvas: Canvas) { + var lines: Array = []; + + for (pos => pixel in canvas){ + if (lines[pos.y] == null) { + lines[pos.y] = ""; + } + + if (lines[pos.y].length < pos.x) { + lines[pos.y] += NativeStringTools.rep(" ", pos.x - lines[pos.y].length); + } + + lines[pos.y] = lines[pos.y].substr(0, pos.x) + pixel.char + lines[pos.y].substr(pos.x + 1); + } + + Log.debug("\n" + lines.join("\n")); + } + #if webconsole public static function printWeb(msg:String) { HTTP.request("http://127.0.0.1:8080/"+Net.instance.networkID,msg);