All Projects → Brooooooklyn → Canvas

Brooooooklyn / Canvas

Licence: mit
High performance skia binding to Node.js. Zero system dependency and pure npm packages without any postinstall scripts nor node-gyp.

Programming Languages

rust
11053 projects

Labels

Projects that are alternatives of or similar to Canvas

Minipaint
online image editor
Stars: ✭ 1,014 (+1509.52%)
Mutual labels:  canvas
Glslcanvas
Simple tool to load GLSL shaders on HTML Canvas using WebGL
Stars: ✭ 1,067 (+1593.65%)
Mutual labels:  canvas
Svelte Canvas
🎨 Reactive canvas rendering with Svelte.
Stars: ✭ 59 (-6.35%)
Mutual labels:  canvas
Gomoku
this is a Gomoku game's client and server, which bulid by canvas and swoole
Stars: ✭ 44 (-30.16%)
Mutual labels:  canvas
Mopaint
🎨💪 Modern, modular paint and more! (pre-alpha, not much done yet)
Stars: ✭ 50 (-20.63%)
Mutual labels:  canvas
Android Toy
不积跬步 无以至千里
Stars: ✭ 54 (-14.29%)
Mutual labels:  canvas
Cnblogs
💘🍦🙈 残梦a博客园样式,本博客的样式一直在更新中,还会不断优化页面的加载速度,坚持每周都会更新自己的博客内容,坚持自己选择计算机的道路 -> https://www.cnblogs.com/sunhang32
Stars: ✭ 41 (-34.92%)
Mutual labels:  canvas
Tower game
💒 盖楼游戏 html5 canvas tower building game 🏢🏬🏦🏯🏰
Stars: ✭ 1,110 (+1661.9%)
Mutual labels:  canvas
Vue Luck Draw
🎖🎖🎖 一个基于 vue2 / vue3 的【大转盘 / 九宫格】抽奖插件;🎉 A lucky draw plug-in based on vue2 / vue3;🎨 奖品 / 文字 / 图片 / 颜色 / 按钮均可配置,支持同步 / 异步抽奖,🎯 概率前 / 后端可控,自动根据 dpr 调整清晰度适配移动端
Stars: ✭ 1,056 (+1576.19%)
Mutual labels:  canvas
Calendar Graph
Calendar graph like github using jsx support SVG, Canvas and SSR
Stars: ✭ 58 (-7.94%)
Mutual labels:  canvas
Smileyrating
SmileyRating is a simple rating bar for android. It displays animated smileys as rating icon.
Stars: ✭ 1,038 (+1547.62%)
Mutual labels:  canvas
Literallycanvas
A canvas in your browser. Literally.
Stars: ✭ 1,043 (+1555.56%)
Mutual labels:  canvas
Deep Viz
A React component library, providing concise and beautiful diversity charts with Canvas, SVG, E-map, WebGL, Dom, based on data visualization experience and commercial data display practice.
Stars: ✭ 55 (-12.7%)
Mutual labels:  canvas
Drawing Board
在线画板,基于 Canvas 和 JavaScript 的画图工具。
Stars: ✭ 44 (-30.16%)
Mutual labels:  canvas
Watchcarslearn
Self driving cars using NEAT
Stars: ✭ 59 (-6.35%)
Mutual labels:  canvas
Color.js
Extract colors from an image (0.75 KB) 🎨
Stars: ✭ 42 (-33.33%)
Mutual labels:  canvas
Gobang html5
五子棋,gobang,html5,canvas,js游戏,普通ai算法
Stars: ✭ 53 (-15.87%)
Mutual labels:  canvas
Tetr.js
🕹️ Tetris clone in HTML5 and JavaScript
Stars: ✭ 60 (-4.76%)
Mutual labels:  canvas
Elm Canvas
Making the canvas API accessible within Elm
Stars: ✭ 60 (-4.76%)
Mutual labels:  canvas
React Handy Renderer
✏️ Draw 2D primitives in sketchy style with React
Stars: ✭ 56 (-11.11%)
Mutual labels:  canvas

@napi-rs/canvas

CI

Google Skia binding to NodeJS via N-API.

⚠️ This project is in very early stage.
For details on planned features and future direction please refer to the Roadmap.

Support matrix

node10 node12 node14 node15
Windows x64
macOS x64
Linux x64

Usage

const { promises } = require('fs')
const { join } = require('path')

const { createCanvas } = require('@napi-rs/canvas')

const canvas = createCanvas(1024, 768)

const ctx = canvas.getContext('2d')

ctx.lineWidth = 10
ctx.strokeStyle = '#03a9f4'
ctx.fillStyle = '#03a9f4'

// Wall
ctx.strokeRect(75, 140, 150, 110)

// Door
ctx.fillRect(130, 190, 40, 60)

// Roof
ctx.beginPath()
ctx.moveTo(50, 140)
ctx.lineTo(150, 60)
ctx.lineTo(250, 140)
ctx.closePath()
ctx.stroke()

async function main() {
  const pngData = await canvas.png()
  // encoding in libuv thread pool, non-blocking
  await promises.writeFile(join(__dirname, 'simple.png'), pngData)
}

main()

Features

Path2D

new Path2D()
new Path2D(path: Path2D)
// new Path2D('M108.956,403.826c0,0,0.178,3.344-1.276,3.311  c-1.455-0.033-30.507-84.917-66.752-80.957C40.928,326.18,72.326,313.197,108.956,403.826z')
new Path2D(path: string)
export interface DOMMatrix2DInit {
  a: number
  b: number
  c: number
  d: number
  e: number
  f: number
}

export class Path2D {
  constructor(path?: Path2D | string)

  addPath(path: Path2D, transform?: DOMMatrix2DInit): void
  arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void
  arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void
  bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void
  closePath(): void
  ellipse(
    x: number,
    y: number,
    radiusX: number,
    radiusY: number,
    rotation: number,
    startAngle: number,
    endAngle: number,
    anticlockwise?: boolean,
  ): void
  lineTo(x: number, y: number): void
  moveTo(x: number, y: number): void
  quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void
  rect(x: number, y: number, w: number, h: number): void
}

Example

The tiger.json was serialized from gojs/samples/tiger

Building

You can build this project from source, with no OS-specific package installing commands required:

# Clone the code:
$ git clone --recurse-submodules https://github.com/Brooooooklyn/canvas.git
$ cd canvas

# Build Skia:
$ node scripts/build-skia.js

# Install NPM packages, build the Node.js addon:
$ yarn install --ignore-scripts
$ yarn run build

# All done! Run test cases or examples now:
$ yarn test
$ node example/tiger.js
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].