🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

canvaskit-wasm

Package Overview
Dependencies
Maintainers
10
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canvaskit-wasm

A WASM version of Skia's Canvas API

0.40.0
latest
npm
Version published
Weekly downloads
331K
8.11%
Maintainers
10
Weekly downloads
 
Created

What is canvaskit-wasm?

The canvaskit-wasm npm package is a high-performance 2D graphics library that provides a WebAssembly (WASM) port of Skia, the graphics engine used in Google Chrome and Android. It allows developers to create complex graphics and animations directly in the browser with high efficiency.

What are canvaskit-wasm's main functionalities?

Drawing Shapes

This code initializes CanvasKit, creates a canvas surface, and draws a blue rectangle on it.

const CanvasKitInit = require('canvaskit-wasm');
CanvasKitInit().then(CanvasKit => {
  const surface = CanvasKit.MakeCanvasSurface('canvas');
  const canvas = surface.getCanvas();
  const paint = new CanvasKit.SkPaint();
  paint.setColor(CanvasKit.Color(0, 0, 255, 1.0));
  canvas.drawRect(CanvasKit.LTRBRect(10, 10, 100, 100), paint);
  surface.flush();
});

Text Rendering

This code initializes CanvasKit, creates a canvas surface, and renders the text 'Hello, CanvasKit!' on it.

const CanvasKitInit = require('canvaskit-wasm');
CanvasKitInit().then(CanvasKit => {
  const surface = CanvasKit.MakeCanvasSurface('canvas');
  const canvas = surface.getCanvas();
  const paint = new CanvasKit.SkPaint();
  paint.setColor(CanvasKit.Color(0, 0, 0, 1.0));
  paint.setTextSize(30);
  canvas.drawText('Hello, CanvasKit!', 10, 40, paint);
  surface.flush();
});

Image Manipulation

This code initializes CanvasKit, creates a canvas surface, and draws an image onto the canvas once it has loaded.

const CanvasKitInit = require('canvaskit-wasm');
CanvasKitInit().then(CanvasKit => {
  const surface = CanvasKit.MakeCanvasSurface('canvas');
  const canvas = surface.getCanvas();
  const img = new Image();
  img.src = 'path/to/image.png';
  img.onload = () => {
    const skImage = CanvasKit.MakeImageFromCanvasImageSource(img);
    canvas.drawImage(skImage, 0, 0, null);
    surface.flush();
  };
});

Other packages similar to canvaskit-wasm

FAQs

Package last updated on 31 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts