• Stars
    star
    109
  • Rank 319,077 (Top 7 %)
  • Language
    C++
  • License
    Apache License 2.0
  • Created about 2 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Fast HTML Canvas API implementation for Deno using Skia.

Skia Canvas

Tags Doc Checks License Sponsor

Fast HTML Canvas API implementation for Deno using Skia.

Example

import { createCanvas } from "https://deno.land/x/[email protected]/mod.ts";

const canvas = createCanvas(300, 300);
const ctx = canvas.getContext("2d");

// Set line width
ctx.lineWidth = 10;

// 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();

canvas.save("image.png");

Usage

Since this library depends on the unstable FFI API, you must pass --allow-env, --allow-ffi and --unstable flags. Without it, the module will fail to find and open native library.

deno run --allow-ffi --allow-env --unstable <file>
# or just
deno run -A --unstable <file>

API

Check the API reference here.

Since this module implements the Canvas Web API, you can also refer to the MDN docs.

Non-standard APIs

For non-standard APIs, see to the API reference mentioned above.

  • Canvas#save - save canvas render as file
  • Canvas#encode - encode render into in-memory buffer
  • Image - provides utility to load image files for drawing on canvas
  • Fonts - provides utility to manage fonts used by Skia
  • PdfDocument - create PDF documents using 2D Canvas API
  • SvgCanvas - like Canvas but creates an SVG as output instead
  • Several additional methods in Path2D object such as toSVGString, simplify, difference, xor, etc.

Benchmarks

Benchmark Results

Source: bench/main.js

Building

First you need to setup depot_tools.

Then, clone the repository with submodules.

And run the following commands:

deno task build-skia
deno task build

By default, the module will download and cache the prebuilt binaries for your platform. However this is not intended behavior when developing locally. To use locally built binaries, set DENO_SKIA_LOCAL environment variable to 1. Or you can also set DENO_SKIA_PATH to a complete path to dynamic library built from the native directory.

License

Apache-2.0 licensed.

Copyright 2022-present Β© DjDeveloperr

More Repositories

1

deno-canvas

Canvas API for Deno, ported from canvaskit-wasm (Skia).
JavaScript
153
star
2

deno_desktop

Windowing support for Deno WebGPU.
Rust
55
star
3

deno_win32

Fast and complete Win32 API bindings for Deno using FFI
TypeScript
37
star
4

ytdl_core

YouTube Video Downloader module for Deno using Web Streams API.
TypeScript
32
star
5

ActivitiesBot

Discord Slash Commands bot to lauch Voice Channel Activities.
TypeScript
24
star
6

deno_serial

Serialport API for Deno.
TypeScript
20
star
7

NSBall

NativeScript Ball demo for macOS
TypeScript
19
star
8

deno_objc

Objective-C runtime bridge for Deno
TypeScript
18
star
9

deno_gl

[WIP] WebGL API implementation for Deno, built on GLFW using FFI.
TypeScript
17
star
10

DenoGBA

Deno GBA Emulator.
TypeScript
16
star
11

Dename

DNS Server framework for Deno.
TypeScript
15
star
12

Keydb

Simple Key-value storage module with support for multiple database backends.
TypeScript
11
star
13

MusicBox

Lavalink-powered Music Slash Bot, made with Harmony.
TypeScript
9
star
14

RPCord

Module to interact with Discord IPC.
TypeScript
8
star
15

TicTacToe

Play Tic Tac Toe in Discord.
TypeScript
7
star
16

deno_namedpipe

Asynchronous Named Pipes support for Deno, built on WinAPI using FFI.
TypeScript
7
star
17

Tesseract-Deno

Deno wrapper for Tesseract OCR engine CLI.
TypeScript
6
star
18

Minesweeper

Serverless Minesweeper Discord Bot
TypeScript
5
star
19

Manga

Manga Reader application & API made with Fresh
TypeScript
5
star
20

deno_ffi

Foreign Function Interface Plugin for Deno.
Rust
4
star
21

deno_threadsafe_callback_poc

[PoC] Thread Safe Callbacks in Deno FFI
Rust
4
star
22

deno_bot

Runs user code in Deno runtime through Message Context Menu commands.
TypeScript
4
star
23

ytmusic_rpc

Discord Rich Presence for YouTube Music
JavaScript
4
star
24

segappend

Append custom data by creating a new segment in compiled binary.
C++
3
star
25

denocc

TCC bindings for Deno
TypeScript
3
star
26

fetch-base64

A simple module to fetch Base64 data of any image/gif, remote or local.
TypeScript
3
star
27

deno_depchecker

Analyze dependencies in your Deno project.
TypeScript
3
star
28

Raqote-Deno

Raqote bindings for Deno.
Rust
3
star
29

ScriptableTSX

https://scriptable.app but with TypeScript(X). Make iOS widgets with TSX.
TypeScript
3
star
30

Glslang-Deno

Compile GLSL to SPIR-V binary. Port of @webgpu/glslang (NPM).
JavaScript
3
star
31

deno_cryptr

Deno port of Node.js `cryptr` using Web Crypto API
TypeScript
2
star
32

struct

C-style struct utility for Deno.
TypeScript
2
star
33

PostQuery

An easy to use Query Client for Deno Postgres.
TypeScript
2
star
34

deno_ipc

Deno module to interact with local sockets.
Rust
2
star
35

deno_winrt

Windows Runtime bindings for Deno.
TypeScript
2
star
36

serde_to_v8

Converts Serde `Value` to v8 binary format.
JavaScript
2
star
37

fast_sqlite3

(wip) experiment with high performance sqlite3 bindings for js
JavaScript
2
star
38

SqliteWorker

Deno SQLite embedded in Worker for async interfacing.
TypeScript
2
star
39

DenoSerialPort

Rust
2
star
40

sd-sprites

1
star
41

serde-window-handle

Serde-compatible window handle types, inter-convertible with raw-window-handle.
Rust
1
star
42

ban_appeal_plugin

Ban Appeals plugin for Modmail bot, with a site to submit appeals.
Python
1
star
43

WatchfaceEditor

Watchface Editor for Mi Band 4/5/6
JavaScript
1
star
44

deno_ffi_v8_poc

[POC] Deno FFI implementation using V8 bindings
Rust
1
star
45

nekoslife-deno

Nekos.life API wrapper for Deno.
TypeScript
1
star
46

CustomTitlebar

A simple tutorial on how to make a custom title-bar with Electron
CSS
1
star
47

IteratorHelpers

Polyfill for the Iterator Hepers proposal.
TypeScript
1
star
48

fastmac

Shell
1
star
49

discord-docs-parser

Discord API Docs parser that can auto-generate API types for payloads, enums and endpoints.
TypeScript
1
star
50

ModuleCache

Global module cache for all modules.
TypeScript
1
star
51

Band

TypeScript
1
star
52

.github

1
star
53

slash.deno.dev

TypeScript
1
star
54

slash-test

TypeScript
1
star