-
Notifications
You must be signed in to change notification settings - Fork 666
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1045 from aleen42/master
Fix wrong global definition genereated by Webpack in UMD styles
- Loading branch information
Showing
6 changed files
with
73 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Demos | ||
|
||
This folder contains examples of ways you can use VexFlow. | ||
|
||
To run the demos, first build the VexFlow library by running `npm install` and then `grunt` from the main folder. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Using VexFlow in Node JS | ||
|
||
You can use VexFlow in Node JS by calling `const Vex = require(...)` on the JS library. | ||
|
||
`node canvas.js > output.html` creates an HTML page containing the VexFlow output. | ||
|
||
`node svg.js > output.svg` creates a SVG image file containing the VexFlow output. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// node canvas.js > output.html | ||
|
||
const { createCanvas } = require('canvas'); | ||
const Vex = require('../../build/vexflow-debug'); | ||
const VF = Vex.Flow; | ||
|
||
const canvas = createCanvas(500, 500); | ||
|
||
const renderer = new VF.Renderer(canvas, VF.Renderer.Backends.CANVAS); | ||
const context = renderer.getContext(); | ||
context.setFont('Arial', 10, '').setBackgroundFillStyle('#eed'); | ||
|
||
const stave = new VF.Stave(10, 40, 400); | ||
stave.addClef('treble'); | ||
stave.addTimeSignature('4/4'); | ||
stave.setContext(context).draw(); | ||
|
||
console.log(`<!DOCTYPE html><html><body><img src="${canvas.toDataURL()}"></body></html>`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// node svg.js > output.svg | ||
|
||
const Vex = require('../../build/vexflow-debug'); | ||
const { JSDOM } = require('jsdom'); | ||
const fs = require('fs'); | ||
|
||
const VF = Vex.Flow; | ||
|
||
const dom = new JSDOM('<!DOCTYPE html><html><body><div id="vf"></div><body></html>'); | ||
|
||
global.document = dom.window.document; | ||
|
||
// Create an SVG renderer and attach it to the DIV element named "vf". | ||
const div = document.getElementById('vf'); | ||
const renderer = new VF.Renderer(div, VF.Renderer.Backends.SVG); | ||
|
||
// Configure the rendering context. | ||
renderer.resize(500, 500); | ||
const context = renderer.getContext(); | ||
context.setFont('Arial', 10, '').setBackgroundFillStyle('#eed'); | ||
|
||
// Create a stave of width 400 at position 10, 40 on the canvas. | ||
const stave = new VF.Stave(10, 40, 400); | ||
|
||
// Add a clef and time signature. | ||
stave.addClef('treble').addTimeSignature('4/4'); | ||
|
||
// Connect it to the rendering context and draw! | ||
stave.setContext(context).draw(); | ||
|
||
const svg = div.innerHTML.replace('<svg ', '<svg xmlns="http://www.w3.org/2000/svg" '); | ||
|
||
console.log(svg); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters