Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/p3tecracknell/rasterise-triangle
A small NodeJS library for rasterising triangles. Designed and tested using node-canvas
https://github.com/p3tecracknell/rasterise-triangle
canvas npm pixel rasterise rasterize triangle
Last synced: 9 days ago
JSON representation
A small NodeJS library for rasterising triangles. Designed and tested using node-canvas
- Host: GitHub
- URL: https://github.com/p3tecracknell/rasterise-triangle
- Owner: p3tecracknell
- License: apache-2.0
- Created: 2018-06-22T22:34:18.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-09-15T22:53:47.000Z (about 4 years ago)
- Last Synced: 2024-10-28T17:55:21.888Z (20 days ago)
- Topics: canvas, npm, pixel, rasterise, rasterize, triangle
- Language: JavaScript
- Homepage:
- Size: 63.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
A small NodeJS library for rasterising triangles. Ideal if using a Canvas (server or client side)
```javascript
const Canvas = require('canvas')
const rasterise = require('rasterise-triangle')const width = 100
const height = 100const canvas = Canvas.createCanvas(width, height)
const ctx = canvas.getContext('2d')const imgData = ctx.getImageData(0, 0, width, height)
const data = imgData.datavar triangle = {
points: [
{x: 0, y: 0 },
{x: 50, y: 50 },
{x: 5, y: 50 }
],
color: [255, 0, 0, 1]
}rasterise.fillTriangle(triangle, data, width, height)
ctx.putImageData(imgData, 0, 0)
console.log('')
```### Installation
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js.
Installation is done using the npm install command:
```
$ npm install express
```### Acknowledgements
Inspired by a Stack Overflow [answer](https://stackoverflow.com/questions/49047229/draw-a-triangle-to-pixel-array).