forked from krethh/spiewnik-szant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_chord.js
executable file
·51 lines (42 loc) · 1.31 KB
/
generate_chord.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env node
'use strict';
const { SVGuitarChord } = require('svguitar');
// import domino from 'domino';
const { createSVGWindow } = require('svgdom');
const { registerWindow } = require('@svgdotjs/svg.js');
const { saveSvgAsPng } = require('save-svg-as-png');
// var domimpl = domino.createDOMImplementation();
// var document = domimpl.createHTMLDocument();
// var window = domino.createWindow('<div id="chart"></div>');
// var document = window.document;
const window = createSVGWindow();
const document = window.document;
global.window = window;
global.document = document;
console.log(global);
const settings = {
"style": "handdrawn",
"strings": 6,
"frets": 4,
"nutSize": 0.65,
"titleFontSize": 48,
"color": "#000",
"strokeWidth": 3,
"fretSize": 1.6,
"backgroundColor": "none",
"fixedDiagramPosition": false,
"tuning": ["E","A","D","G","h","e"]
}
const A7 = {
"title": "A7",
"position": 1,
"fingers": [[4,2],[2,2],[6,"x"],[5,0],[3,0],[1,0]],
"barres": []
}
// const chart = new SVGuitarChord(document.querySelector('#chart'));
const chartElement = document.documentElement;
// chartDiv.setAttribute('id', 'chart');
const chart = new SVGuitarChord(chartElement);
chart.chord(A7).configure(settings);
const svg = chart.innerHtml;
saveSvgAsPng(svg, 'test.png');