Skip to content

Commit

Permalink
New SVGContext and testing
Browse files Browse the repository at this point in the history
Creates new SVGContext, to remove dependency on Raphael.
Replaces runTest & runRaphaelTest with runTests(), which runs test in
backgrounds as configured in vexflow_test_helpers.js
  • Loading branch information
gristow authored and 0xfe committed Jan 24, 2015
1 parent fc389ee commit 3a7425a
Show file tree
Hide file tree
Showing 45 changed files with 944 additions and 447 deletions.
4 changes: 2 additions & 2 deletions docs/sandbox.html
Expand Up @@ -8,8 +8,8 @@
type="text/css" />

<!-- VexFlow Compiled Source -->
<script src="../build/vexflow/vexflow-debug.js"></script>
<script src="../support/vexflow-min.js"></script>
<script src="../build/vexflow-debug.js"></script>
<!-- <script src="../build/vexflow-min.js"></script> -->

<!-- Support Sources -->
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
Expand Down
4 changes: 4 additions & 0 deletions src/raphaelcontext.js
Expand Up @@ -5,6 +5,10 @@
//
// Copyright Mohit Cheppudira 2010

// ## Warning: Deprecated for SVGContext
// Except in instances where SVG support for IE < 9.0 is
// needed, SVGContext is recommended.

/** @constructor */
Vex.Flow.RaphaelContext = (function() {
function RaphaelContext(element) {
Expand Down
12 changes: 12 additions & 0 deletions src/renderer.js
Expand Up @@ -33,6 +33,7 @@ Vex.Flow.Renderer = (function() {

Renderer.buildContext = function(sel,
backend, width, height, background) {

var renderer = new Renderer(sel, backend);
if (width && height) { renderer.resize(width, height); }

Expand All @@ -52,6 +53,12 @@ Vex.Flow.Renderer = (function() {
width, height, background);
};

Renderer.getSVGContext = function(sel, width, height, background) {
return Renderer.buildContext(sel, Renderer.Backends.SVG,
width, height, background);
};


Renderer.bolsterCanvasContext = function(ctx) {
if (Renderer.USE_CANVAS_PROXY) {
return new Vex.Flow.CanvasContext(ctx);
Expand Down Expand Up @@ -123,8 +130,13 @@ Vex.Flow.Renderer = (function() {
"Can't get canvas context from element: " + sel);
this.ctx = Renderer.bolsterCanvasContext(
this.element.getContext('2d'));

} else if (this.backend == Renderer.Backends.RAPHAEL) {
this.ctx = new Vex.Flow.RaphaelContext(this.element);

} else if (this.backend == Renderer.Backends.SVG) {
this.ctx = new Vex.Flow.SVGContext(this.element);

} else {
throw new Vex.RERR("InvalidBackend",
"No support for backend: " + this.backend);
Expand Down

0 comments on commit 3a7425a

Please sign in to comment.