https://github.com/planetis-m/jscanvas
A Nim wrapper for the Canvas API
https://github.com/planetis-m/jscanvas
Last synced: 2 months ago
JSON representation
A Nim wrapper for the Canvas API
- Host: GitHub
- URL: https://github.com/planetis-m/jscanvas
- Owner: planetis-m
- License: other
- Created: 2019-10-08T10:17:04.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-09-09T13:53:07.000Z (almost 4 years ago)
- Last Synced: 2024-05-02T04:20:17.686Z (about 1 year ago)
- Language: Nim
- Size: 3.91 KB
- Stars: 14
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: copying.txt
Awesome Lists containing this project
README
# JsCanvas — A Nim wrapper for the [Canvas API](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API)
## Example
```nim
import jscanvas, colors, dom, mathvar canvas = document.getElementById("canvas").CanvasElement
canvas.width = 480
canvas.height = 320var ctx = canvas.getContext2d()
# Draw a ball
var x = canvas.width div 2
var y = canvas.height - 30
var ballRadius = 10ctx.beginPath()
ctx.arc(x, y, ballRadius, 0, Pi*2)
ctx.fillStyle = $colBlack # could also be: $rgb(0, 0, 0) or just "rgb(0,0,0)"
ctx.fill()
ctx.closePath()
```