Vexflow: Is there a minimalist example ? If not should I create one ?

Created on 3 Jun 2018  路  2Comments  路  Source: 0xfe/vexflow

I was looking through the documentation for a minimalist example.

Of course there is the material here https://github.com/0xfe/vexflow/wiki/The-VexFlow-Tutorial but that doesn't tell me what JS/CSS files need to be included.

I think it would be good if the docs contained a working HTML page with the minimal js/css includes. I'm willing to do a PR if there's not one already which I have overlooked.

Here's my work in progress (although this doesn't actually work as it throws an error). This is based on

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <script src="https://unpkg.com/vexflow/releases/vexflow-debug.js" crossorigin="anonymous"></script>
    <script>

        VF = Vex.Flow;

        // Create an SVG renderer and attach it to the DIV element named "boo".
        var div = document.getElementById("boo")
        var renderer = new VF.Renderer(div, VF.Renderer.Backends.SVG);

        // Configure the rendering context.
        renderer.resize(500, 500);
        var context = renderer.getContext();
        context.setFont("Arial", 10, "").setBackgroundFillStyle("#eed");

        // Create a stave of width 400 at position 10, 40 on the canvas.
        var 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();
    </script>
    <title>Minimal</title>
  </head>
  <body>
    <div class="container">
        <h1>Minimalist Vexflow Example</h1>
    </div>
    <div id="boo"></div>
  </body>
</html>

Most helpful comment

The README now has a minimalist example.

All 2 comments

I would also appreciate a minimalist local Vexflow example build.
@shearichard I tried pretty much the same as you, and also got an error. The problem is that you can't easily directly import the vexflow-debug.js in the html and then import Vex or _vex in your script like you tried above, because vexflow-debug exports Vex as a webpack module.
(btw, try