// Get the rendering context
var canvas = $("div.sandbox div.sandbox canvas")[0];
var renderer = new Vex.Flow.Renderer(canvas,
Vex.Flow.Renderer.Backends.CANVAS);
var ctx = renderer.getContext();
renderer.resize(400, 300); // Resize and clear canvas
ctx.setFont("Arial", 10, "").setBackgroundFillStyle("#eed");
// Create stave
var stave = new Vex.Flow.Stave(10, 0, 300);
stave.addClef('bass');
var keysig = new Vex.Flow.KeySignature('C');
keysig.addToStave();
stave.setContext(ctx).draw();
var notes = [ new Vex.Flow.StaveNote({ keys: ['C/2'], duration: "q" })
];
var voice = new Vex.Flow.Voice({
num_beats: 1,
beat_value: 4,
resolution: Vex.Flow.RESOLUTION
});
voice.addTickables(notes);
var formatter = new Vex.Flow.Formatter().joinVoices([voice]).format([voice], 300);
voice.draw(ctx, stave);