Skip to content

Commit

Permalink
Added vexflow canvas scaling.
Browse files Browse the repository at this point in the history
  • Loading branch information
rubiety committed Jan 22, 2012
1 parent f33cf44 commit 34050c3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.rdoc
Expand Up @@ -34,6 +34,18 @@ By default jquery-vexflow will determine width and height of the element, either
Alternately, the vexflow method accepts an optional second argument with render options (width and height) which will force width/height:

$("#my-chord").vexflow(["C", "E", "G"], { width: 400, height: 150 });

== Scaling

You can change the scale of the rendering with the data-scale attribute:

<div class="staff" data-clef="treble" data-staff='["C", "E", "G", "Bb"]' data-scale="0.75" />

$(".staff").vexflow();

Or specify it as an optional second argument with render options:

$("#my-chord").vexflow(["C", "E", "G"], { scale: 0.75 });

== Clef(s)

Expand Down
6 changes: 6 additions & 0 deletions examples.html
Expand Up @@ -20,6 +20,12 @@ <h2>Simple Chord</h2>
$("#simple-chord").vexflow(["C", "E", "G", "Bb"]);
</script>

<h2>Simple Chord</h2>
<div id="simple-chord-scaled" data-scale="0.75" width="200"></div>
<script type="text/javascript">
$("#simple-chord-scaled").vexflow(["C", "E", "G", "Bb"]);
</script>

<h2>Simple Chord with Octaves</h2>
<div id="simple-chord-with-octaves"></div>
<script type="text/javascript">
Expand Down
1 change: 1 addition & 0 deletions jquery.vexflow.js
Expand Up @@ -30,6 +30,7 @@
if (!render_options) { render_options = {}; }
if (!render_options.width) { render_options.width = $(element).attr("data-width") || $(element).attr("width") || 600; }
if (!render_options.height) { render_options.height = $(element).attr("data-height") || $(element).attr("height") || 110; }
if (!render_options.scale) { render_options.scale = parseFloat($(element).attr("data-scale") || "1"); }
if (!render_options.clef && $(element).attr("data-clef")) { render_options.clef = $(element).attr("data-clef").split(","); }

var canvas_element = $("<canvas width='" + render_options.width + "' height='" + render_options.height + "'></canvas>");
Expand Down

0 comments on commit 34050c3

Please sign in to comment.