canvas_test.nim 607 B

1234567891011121314151617181920
  1. import canvas, dom
  2. proc onLoad() {.exportc.} =
  3. var canvas = document.getElementById("canvas").EmbedElement
  4. canvas.width = window.innerWidth
  5. canvas.height = window.innerHeight
  6. var ctx = canvas.getContext("2d")
  7. ctx.fillStyle = "#1d4099"
  8. ctx.fillRect(0, 0, window.innerWidth, window.innerHeight)
  9. ctx.strokeStyle = "#ffffff"
  10. let letterWidth = 100
  11. let letterLeftPos = (window.innerWidth div 2) - (letterWidth div 2)
  12. ctx.moveTo(letterLeftPos, 320)
  13. ctx.lineTo(letterLeftPos, 110)
  14. ctx.lineTo(letterLeftPos + letterWidth, 320)
  15. ctx.lineTo(letterLeftPos + letterWidth, 110)
  16. ctx.stroke()