项目作者: folkdb

项目描述 :
Render VexTab to SVG in a Node environment
高级语言: JavaScript
项目地址: git://github.com/folkdb/vextab-render-svg.git
创建时间: 2020-06-26T02:57:53Z
项目社区:https://github.com/folkdb/vextab-render-svg

开源协议:ISC License

下载


@folkdb/vextab-render-svg

Render VexTab to SVG in a Node environment

Install

  1. npm i @folkdb/vextab-render-svg

Usage

This package is released as an ES module only. Minimum Node.js version is 12 (latest LTS as of release date). CommonJS require() is not supported.

  1. import vextabRenderSvg from '@folkdb/vextab-render-svg'
  2. (async () => {
  3. const svg = await vextabRenderSvg(`
  4. tabstave notation=true key=A time=4/4
  5. notes :q =|: (5/2.5/3.7/4) :8 7-5/3 5h6-7/5 ^3^ :q 7V/4
  6. `);
  7. // do something with SVG
  8. })();

API

The module’s default export is a function with the following parameters:

  1. function(content: string, {
  2. width = 640,
  3. offset = [0, 0],
  4. ...options
  5. } = {}): string

Required

  • content: the VexTab string to be rendered to SVG

Rendering Options

  • width: set the width of the stave in pixels
  • offset: set the [x, y] offset of the stave from the upper-left corner of the canvas
  • options: additional options passed to the VexTab’s Artist constructor