No description
Find a file
Gabriel Lasso 72c4b41bf7
Merge pull request #8 from GabrielLasso/fix-screen-size-on-retina
Use getFramebufferSize to get actual screen size
2021-09-21 09:56:06 -03:00
examples Add game of life 2021-09-16 22:42:19 -03:00
src Use @filipux sugestion 2021-09-20 19:28:10 -03:00
tests First commit 2021-07-09 21:03:23 -03:00
.gitignore Remove js file 2021-08-28 10:34:09 -03:00
docs.md Update docs.md 2021-09-13 22:12:42 -03:00
drawim.nimble v0.1.2 2021-09-16 22:44:22 -03:00
LICENSE Create LICENSE 2021-08-28 10:45:56 -03:00
README.md Update README.md 2021-09-14 21:51:43 -03:00

Drawim

A simple drawing library in Nim, inspired by p5js. Builds to native, using OpenGL, and to JavaScript, using HTML5 Canvas.

Usage

A simple example, to draw a rectangle:

import drawim

proc draw() =
  background(0)
  fill(255, 0, 0)
  translate(int(width / 2), int(height / 2))
  rectFill(-100,-100,100,100)

run(600, 400, draw, name = "Drawim example")

To run the example, you can either nim r example.nim or nim js example.nim and include the resulting js in an HTML file containing a div with id="Drawim example".

More examples can be found on examples/ folder.

Installation

Just install with numble by running

nimble install drawim

Features

  • Compiles to native and JS
  • 100% Nim code
  • Basic drawing
  • Read keyboard and mouse input
  • Limit the framerate
  • Rotate, translate and scale
  • Save transform state in a stack (see examples/tree.nim)
  • RGB and HSV colors
  • Bezier curves
  • Easy to extend and create new curves

To do:

  • Stroke weight
  • Sprites
  • Fonts
  • Unit tests

Documentation

You can find the full docs here