Skip to content

Commit

Permalink
added documentation; removed return statements in Interface.js
Browse files Browse the repository at this point in the history
  • Loading branch information
aerhard committed Jul 5, 2014
1 parent c4a074d commit eac4b20
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ arguments:

- `xmlDoc` (XMLDocument) should be a markup fragment containing the MEI

- `target` (Element) should be an HTML <canvas> element onto which the notation
- `target` (Element) should be an HTML <canvas> or <svg> element onto which the notation
will be drawn

- `width` (Number) should be the width of the canvas in pixels. Defaults to 800 (optional)
Expand Down
76 changes: 60 additions & 16 deletions src/Interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,86 @@
* @class MEI2VF
* @singleton
*/
var MEI2VF = ( function(m2v, MeiLib, VF, $, undefined) {
var MEI2VF = (function(m2v, MeiLib, VF, $, undefined) {
return {
/**
* enables or disables MEI2VF logging
* @method setLogging
* @param {Boolean} value True if logging should be enabled, false if not. Defaults to false.
*/
setLogging : m2v.setLogging,
/**
* The methods in Converter can be used to manually address distinct
* processing steps and retrieve the created data. Can be used in
* addition or as a supplement to {@link render_notation} and
* {@link rendered_measures}
*/
Converter : {
initConfig : function(c) {
return m2v.Converter.prototype.initConfig(c);
/**
* initializes the converter
* @method initConfig
* @param {Object} config The options passed to the converter. For a list, see
* {@link MEI2VF.Converter#defaults}
*/
initConfig : function(config) {
m2v.Converter.prototype.initConfig(config);
},
process : function(c) {
return m2v.Converter.prototype.process(c);
/**
* Processes the specified MEI document or document fragment. The generated
* objects can be processed further or drawn immediately to a canvas via
* {@link #draw}.
* @method process
* @param {XMLDocument} xmlDoc the XML document
*/
process : function(xmlDoc) {
m2v.Converter.prototype.process(xmlDoc);
},
draw : function(c) {
return m2v.Converter.prototype.draw(c);
/**
* Draws the processed data to a canvas
* @method draw
* @param ctx The canvas context
*/
draw : function(ctx) {
m2v.Converter.prototype.draw(ctx);
},
/**
* returns a 2d array of all Vex.Flow.Stave objects, arranged by
* [measure_n][staff_n]
* @method getAllVexMeasureStaffs
* @return {Vex.Flow.Stave[][]} see {@link MEI2VF.Converter#allVexMeasureStaffs}
*/
getAllVexMeasureStaffs : function() {
return m2v.Converter.prototype.getAllVexMeasureStaffs();
},
/**
* Returns the width and the height of the area that contains all drawn
* staves as per the last processing.
*
* @method getStaffArea
* @return {Object} the width and height of the area that contains all staves.
* Properties: width, height
*/
getStaffArea : function() {
return m2v.Converter.prototype.getStaffArea();
}
},
/**
* @property
* Contains all Vex.Flow.Stave objects created when calling {@link #render_notation}.
* Addressing scheme: [measure_n][staff_n]
* @property {Vex.Flow.Stave[][]} rendered_measures
*/
rendered_measures: null,
/**
* Main rendering function. Uses the Converter's prototype as a
* singleton. No scaling; page layout information in the MEI code is ignored.
* Main rendering function.
* @param {XMLDocument} xmlDoc The MEI XML Document
* @param {XMLElement} target An svg or canvas element
* @param {Number} width The width of the print space in pixels
* @param {Number} height The height of the print space in pixels
* @param {Element} target An svg or canvas element
* @param {Number} width The width of the print space in pixels. Defaults to 800 (optional)
* @param {Number} height The height of the print space in pixels. Defaults to 350 (optional)
* @param {Number} backend Set to Vex.Flow.Renderer.Backends.RAPHAEL to
* render to a Raphael context; if falsy, Vex.Flow.Renderer.Backends.CANVAS
* is set
* is set (optional)
* @param {Object} options The options passed to the converter. For a list, see
* {@link MEI2VF.Converter MEI2VF.Converter}
* {@link MEI2VF.Converter#defaults} (optional)
*/
render_notation: function (xmlDoc, target, width, height, backend, options) {
var ctx;
Expand All @@ -61,5 +105,5 @@ var MEI2VF = ( function(m2v, MeiLib, VF, $, undefined) {

}
};

}(MEI2VF || {}, MeiLib, Vex.Flow, jQuery));

0 comments on commit eac4b20

Please sign in to comment.