Skip to content

Commit 5d786fe

Browse files
Merge pull request #3 from jportela/svg-implementation
Updating demo with SVG implementation
2 parents 0a9bd51 + 8268799 commit 5d786fe

File tree

4 files changed

+70632
-7435
lines changed

4 files changed

+70632
-7435
lines changed

demo/demo.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
nextCursorBtn,
4040
resetCursorBtn,
4141
showCursorBtn,
42-
hideCursorBtn;
42+
hideCursorBtn,
43+
backendSelect;
4344

4445
// Initialization code
4546
function init() {
@@ -57,6 +58,7 @@
5758
resetCursorBtn = document.getElementById("reset-cursor-btn");
5859
showCursorBtn = document.getElementById("show-cursor-btn");
5960
hideCursorBtn = document.getElementById("hide-cursor-btn");
61+
backendSelect = document.getElementById("backend-select");
6062

6163
// Hide error
6264
error();
@@ -85,7 +87,7 @@
8587
};
8688

8789
// Create OSMD object and canvas
88-
OSMD = new opensheetmusicdisplay.OSMD(canvas);
90+
OSMD = new opensheetmusicdisplay.OSMD(canvas, false);
8991
OSMD.setLogLevel('info');
9092

9193
// Set resize event handler
@@ -121,6 +123,16 @@
121123
showCursorBtn.addEventListener("click", function() {
122124
OSMD.cursor.show();
123125
});
126+
127+
backendSelect.addEventListener("change", function(e) {
128+
var value = e.target.value;
129+
// clears the canvas element
130+
canvas.innerHTML = "";
131+
OSMD = new opensheetmusicdisplay.OSMD(canvas, false, value);
132+
OSMD.setLogLevel('info');
133+
selectOnChange();
134+
135+
});
124136
}
125137

126138
function Resize(startCallback, endCallback) {

demo/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ OSMD can display [MusicXML][0] in both `.xml` and `.mxl` containers. On this dem
1414

1515
<select id="select" class="btn btn-demo"></select>
1616

17+
## Renderer
18+
You can select the rendering strategy, by choosing either the Canvas option, or the SVG one.
19+
20+
<select id="backend-select" class="btn btn-demo" value="canvas">
21+
<option value="canvas">Canvas</option>>
22+
<option value="svg">SVG</option>
23+
</select>
24+
1725
## Zoom level
1826
You control the zoom level of the music sheet displayed. Right now, OSMD is rendering the music piece at <span id="zoom-str">100</span>% on <span id="size-str">0</span>px width.
1927

demo/osmd-debug.js

Lines changed: 62541 additions & 31 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)