diff options
Diffstat (limited to 'src/main/kotlin/Renderer.kt')
| -rw-r--r-- | src/main/kotlin/Renderer.kt | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/main/kotlin/Renderer.kt b/src/main/kotlin/Renderer.kt index 3a7111e..49d6b2c 100644 --- a/src/main/kotlin/Renderer.kt +++ b/src/main/kotlin/Renderer.kt @@ -4,18 +4,14 @@ import org.w3c.dom.HTMLCanvasElement class Renderer(val viewportWidth: Int, val viewportHeight: Int, private val outputScale: Int) { - private val canvas = (document.createElement("canvas") as HTMLCanvasElement) + private val canvas = (document.getElementById("render-output") as HTMLCanvasElement) .apply { width = viewportWidth * outputScale height = viewportHeight * outputScale } - private val context = canvas.getContext("2d") as CanvasRenderingContext2D - - init { - context.scale(outputScale.toDouble(), outputScale.toDouble()) - document.body!!.appendChild(canvas) - } + private val context = (canvas.getContext("2d") as CanvasRenderingContext2D) + .apply { scale(outputScale.toDouble(), outputScale.toDouble()) } fun drawLine(startX: Double, startY: Double, endX: Double, endY: Double, cssColour: String = "#FF0000") { context.strokeStyle = cssColour |