MCPcopy
hub / github.com/canvg/canvg

github.com/canvg/canvg @v4.0.3 sqlite

repository ↗ · DeepWiki ↗ · release v4.0.3 ↗
580 symbols 1,387 edges 110 files 17 documented · 3%
README

canvg

Logo

NPM version Dependencies status Build status Coverage status

JavaScript SVG parser and renderer on Canvas. It takes the URL to the SVG file or the text of the SVG file, parses it in JavaScript and renders the result on Canvas. It also can be used to rasterize SVG images.

Quickstart   •   Docs   •   Demo


Quickstart

Install this library using your favorite package manager:

pnpm add canvg
# or
yarn add canvg
# or
npm i canvg

Then, just import Canvg and use it:

import { Canvg } from 'canvg';

let v = null;

window.onload = async () => {
  const canvas = document.querySelector('canvas');
  const ctx = canvas.getContext('2d');

  v = await Canvg.from(ctx, './svgs/1.svg');

  // Start SVG rendering with animations and mouse handling.
  v.start();
};

window.onbeforeunload = () => {
  v.stop();
};

Description of all exports you can find in Documentation.

Docs

What's implemented?

The end goal is everything from the SVG spec. The majority of the rendering and animation is working. If you would like to see a feature implemented, don't hesitate to add it to the issues list, or better is to create pull request 😎

Extension points exported contracts — how you extend this code

ITransform (Interface)
(no doc) [6 implementers]
src/Transform/types.ts
IEventTarget (Interface)
(no doc) [2 implementers]
src/Mouse.ts
ICanvas (Interface)
* `node-canvas` exports.
src/presets/node.ts
Matchers (Interface)
(no doc)
test/common/imageSnapshot.ts
IOptions (Interface)
(no doc)
src/Canvg.ts
IViewPortSize (Interface)
(no doc)
src/ViewPort.ts
IParserOptions (Interface)
(no doc)
src/Parser.ts
IScreenOptions (Interface)
(no doc)
src/Screen.ts

Core symbols most depended-on inside this repo

hasValue
called by 188
src/Property.ts
getPixels
called by 85
src/Property.ts
getString
called by 73
src/Property.ts
getNumber
called by 49
src/Property.ts
setValue
called by 44
src/Property.ts
split
called by 43
src/Property.ts
getDefinition
called by 30
src/Property.ts
addPoint
called by 29
src/BoundingBox.ts

Shape

Method 294
Class 133
Function 130
Interface 23

Languages

TypeScript100%

Modules by API surface

src/Document/TextPathElement.ts35 symbols
test/browser/v2/canvg.js26 symbols
src/Property.ts25 symbols
src/Document/TextElement.ts22 symbols
src/Mouse.ts19 symbols
src/Document/Document.ts19 symbols
src/Screen.ts17 symbols
src/Document/PathElement.ts17 symbols
src/Document/Element.ts16 symbols
src/BoundingBox.ts16 symbols
src/PathParser.ts15 symbols
src/Canvg.ts14 symbols

Dependencies from manifests, versioned

@algolia/client-search4.11.0 · 1×
@babel/core7.6.4 · 1×
@babel/node7.6.3 · 1×
@commitlint/cli16.1.0 · 1×
@commitlint/config-conventional16.0.0 · 1×
@commitlint/cz-commitlint16.1.0 · 1×
@docusaurus/core2.0.0-beta.14 · 1×
@docusaurus/module-type-aliases2.0.0-beta.14 · 1×
@docusaurus/preset-classic2.0.0-beta.14 · 1×
@docusaurus/theme-search-algolia2.0.0-beta.9 · 1×
@mdx-js/react1.6.21 · 1×
@rollup/plugin-commonjs21.0.1 · 1×

For agents

$ claude mcp add canvg \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact