Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

JS Backend

Ethosa edited this page Mar 13, 2023 · 1 revision

Let's start to write your web program ^^

import hapticx

var
  app = newApp("My own app")
  scene = newHScene()
  canvas = newHCanvas()

scene.addChild(canvas)
canvas.drawRect(0, 0, 50, 50, WhiteClr)
canvas.drawRect(48, 48, 64, 64, RedClr)

app.main = scene
app.run()

After this, you need minimal HTML file:

<!DOCTYPE html>
<html>
  <head></head>
  <body>
    <canvas id="app"></canvas>
    <script src="your_program.js"></script>
  </body>
  <style>
    body {
      margin: 0;
      padding: 0;
    }
    #app {
      width: 100vw;
      height: 100vh;
      display: block;
    }
  </style>
</html>

Finally, you can use it:

nim c --noMain:on your_program.nim

Open .html file 🎉

Clone this wiki locally