### Local Development Setup Source: https://github.com/0xfe/vexchords/blob/master/README.md Commands to set up the development environment for the VexChords repository. Includes installing dependencies and starting a local server. ```bash $ npm i $ npm start ``` -------------------------------- ### Install VexChords using npm Source: https://github.com/0xfe/vexchords/blob/master/README.md Install the VexChords library using npm. This is the first step before using it in your project. ```bash npm i vexchords ``` -------------------------------- ### VexChords Examples: Basic and Customized Rendering Source: https://github.com/0xfe/vexchords/blob/master/README.md Demonstrates various ways to use the `vexchords.draw` function, including basic chord rendering, customizing size and default color, and setting specific colors for elements like strokes and bridges. ```javascript import * as vexchords from 'vexchords'; const sel = '#vexchords'; // Draw an open D7 vexchords.draw(sel, { chord: [[1, 2], [2, 1], [3, 2], [4, 0], [5, 'x'], [6, 'x']] }); // Customize size and default color vexchords.draw( sel, { chord: [[1, 2], [2, 1], [3, 2], [4, 0], [5, 'x'], [6, 'x']] }, { width: 200, height: 240, defaultColor: '#745' } ); // Set color of circles and bars only vexchords.draw( sel, { chord: [[2, 3], [3, 3], [4, 3], [6, 'x']], position: 5, barres: [{ fromString: 5, toString: 1, fret: 1 }] }, { strokeColor: '#8a8' } ); // Set colors of bridge and text only vexchords.draw( sel, { chord: [[1, 0], [2, 0], [6, 0]], position: 0, barres: [{ fromString: 5, toString: 3, fret: 2 }] }, { bridgeColor: '#8a8', textColor: '#8a8' } ); // Tiny chords, don't show tuning keys vexchords.draw( sel, { chord: [], position: 1, barres: [ { fromString: 6, toString: 1, fret: 1 }, { fromString: 5, toString: 3, fret: 3 } ] }, { width: 30, height: 40, strokeColor: '#745', showTuning: false } ); ``` -------------------------------- ### Draw Chord with Smaller Dimensions and No Tuning Source: https://github.com/0xfe/vexchords/blob/master/static/test.html Draws the same chord as the first example but with smaller dimensions and no tuning displayed. Useful for compact visualizations. ```javascript draw( sel, { chord: [[1, 2], [2, 1], [3, 2], [4, 0], [5, 'x'], [6, 'x']] }, { width: 30, height: 40, showTuning: false } ); ``` -------------------------------- ### Draw Chord with Different Dimensions and No Tuning Source: https://github.com/0xfe/vexchords/blob/master/static/test.html Draws the same chord as the first example but with different dimensions and no tuning displayed. Useful for variations in visual presentation. ```javascript draw( sel, { chord: [[1, 2], [2, 1], [3, 2], [4, 0], [5, 'x'], [6, 'x']] }, { width: 50, height: 60, showTuning: false } ); ``` -------------------------------- ### Initialize and Draw ChordBox Source: https://github.com/0xfe/vexchords/blob/master/README.md Use the ChordBox class to render a guitar chord. Import `ChordBox` and instantiate it with a selector and optional customizations. Then, use the `draw` method to render the chord with its notes, position, and optional barres and tuning. ```javascript import { ChordBox } from 'vexchords'; const chord = new ChordBox('#selector', { // Customizations (all optional, defaults shown) width: 100, // canvas width height: 120, // canvas height circleRadius: 5, // circle radius (width / 20 by default) numStrings: 6, // number of strings (e.g., 4 for bass) numFrets: 5, // number of frets (e.g., 7 for stretch chords) showTuning: true, // show tuning keys defaultColor: '#666', // default color bgColor: '#FFF', // background color strokeColor: '#666', // stroke color (overrides defaultColor) textColor: '#666', // text color (overrides defaultColor) stringColor: '#666', // string color (overrides defaultColor) fretColor: '#666', // fret color (overrides defaultColor) labelColor: '#666', // label color (overrides defaultColor) fretWidth: 1, // fret width stringWidth: 1, // string width fontFamily, fontSize, fontWeight, fontStyle, // font settings labelWeight // weight of label font }); chord.draw({ // array of [string, fret, label (optional)] chord: [ [1, 2], [2, 1], [3, 2], [4, 0], // fret 0 = open string [5, 'x'], // fret x = muted string [6, 'x'] ], // optional: position marker position: 5, // start render at fret 5 // optional: barres for barre chords barres: [ { fromString: 6, toString: 1, fret: 1 }, { fromString: 5, toString: 3, fret: 3 } ], // optional: tuning keys tuning: ['E', 'A', 'D', 'G', 'B', 'E'] }); ``` -------------------------------- ### Upload Demo Script Source: https://github.com/0xfe/vexchords/blob/master/README.md Command to upload the demo using a provided script. Requires setting the Google Cloud account first. ```bash $ gcloud config set account xxx@gmail.com $ ./upload.sh ``` -------------------------------- ### Initialize Chord Chart Source: https://github.com/0xfe/vexchords/blob/master/static/demo.html Initializes the chord chart by displaying preset open chords and generating barre chords based on E and A shapes for various keys. Finally, it renders all the created chord elements. ```javascript function init() { var container = $('#container'); // Display preset chords (open chords) for (var i = 0; i < chordChart.length; ++i) { var section_struct = chordChart[i]; var section = createSectionElement(section_struct); for (var j = 0; j < section_struct.chords.length; ++j) { section.append(createChordElement(section_struct.chords[j])); } container.append(section); } // Display shape chords for all keys var keys_E = ['F', 'F#', 'Gb', 'G', 'G#', 'Ab', 'A', 'A#', 'Bb', 'C']; var keys_A = ['C#', 'Db', 'D', 'D#', 'Eb', 'F', 'F#', 'Gb', 'G']; var shapes_E = [ 'M E', 'm E', '7 E', 'm7 E', 'M7 E', 'm7b5 E', 'dim E', 'sus4 E', '7sus4 E', '13 E' ]; var shapes_A = [ 'M A', 'm A', '7 A', 'm7 A', 'M7 A', 'm7b5 A', 'dim A', 'sus2 A', 'sus4 A', '7sus4 A', '9 A', '7b9 A', '7#9 A', '13 A' ]; createShapeChart(keys_E, container, shapes_E, 'E'); createShapeChart(keys_A, container, shapes_A, 'A'); // Render chords chords.forEach(chord => { new ChordBox(chord.el, { width: 130, height: 150, defaultColor: '#444' }).draw(chord.struct); }); } $(function() { init(); }); ``` -------------------------------- ### Publishing to npm Source: https://github.com/0xfe/vexchords/blob/master/README.md Steps to publish a new version of VexChords to npm. Ensure the package version is updated in `package.json` before publishing. ```bash # Publish: first update package version in package.json $ npm publish ``` -------------------------------- ### Draw Chord using Helper Function Source: https://github.com/0xfe/vexchords/blob/master/README.md Use the `draw` helper function for a more concise way to render chords. It takes a selector and chord data, with optional customization options. ```javascript import { draw } from 'vexchords'; // Draw an open D7 draw('#selector', { chord: [[1, 2], [2, 1], [3, 2], [4, 0], [5, 'x'], [6, 'x']] }); ``` -------------------------------- ### Create Shape Chart Source: https://github.com/0xfe/vexchords/blob/master/static/demo.html Generates chord charts for different keys using specified shapes (e.g., E shape, A shape). It iterates through keys and shapes to build the chart. ```javascript function createShapeChart(keys, container, shapes, shape) { for (let i = 0; i < keys.length; i += 1) { const key = keys[i]; const section = createSectionElement({ section: `${key} Chords (${shape} Shape)`, description: `${shape}-Shaped barre chords in the key of ${key}.` }); for (let j = 0; j < shapes.length; j += 1) { const chordElem = createChordElement(vexchords.build(key, shape, shapes[j])); section.append(chordElem); } container.append(section); } } ``` -------------------------------- ### Create Section Element Source: https://github.com/0xfe/vexchords/blob/master/static/demo.html Creates a DOM element for a section of chords, including a title and description. This helps organize the chord chart visually. ```javascript function createSectionElement(sectionStruct) { const section = $('