Hi, why the canvas API doesn't work with Kotlin ? ...
# javascript
a
Hi, why the canvas API doesn't work with Kotlin ? I have this code, but nothing is drawn
Copy code
window.onload = {
	val canvas = document.body!!.append.canvas {} as HTMLCanvasElement
	val ctx = canvas.getContext("2d") as CanvasRenderingContext2D
	ctx.fillStyle = "green"
	ctx.fillRect(10.0, 10.0, 100.0, 100.0)
}
r
You are probably creating canvas html element wrong.
a
how should I create it so ?
t
createElement("canvas")
a
okay it's very weird, when putting this code directly in
main
it works 🤔
without the
window.onload
but the weirder is that I still can't use my PIXI-Kotlin project, I tried a lot of things and it still shows nothing, I made an earlier message in this channel :/