GithubHelp home page GithubHelp logo

chordproject / chord-diagrammer Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 0.0 277 KB

A TypeScript library to generate SVG chord diagrams.

Home Page: https://chordproject.com

License: MIT License

TypeScript 93.05% JavaScript 6.95%
typescript chord chord-diagram music song svg

chord-diagrammer's Introduction

Chord Diagrammer

A TypeScript library to generate SVG chord diagrams.

Inspired by: https://github.com/tombatossals/react-chords.

Part of ChordProject

Overview

Generates SVG chord diagrams according to received specifications.

Diagrams

Usage

Chord Diagrammer is on npm. To install run:

$ npm i chordproject-editor

It's really easy to draw an SVG chord diagram:

// chord diagram definitions
const chordDiagram = new ChordDiagram({
    frets: [-1, 0, 2, 2, 1, 0],
    fingers: [0, 0, 2, 3, 1, 0],
    baseFret: 1,
});

// instrument definitions
const instrument = {
    strings: 6,
    fretsOnChord: 4,
    name: "Guitar",
    tunings: ["E", "A", "D", "G", "B", "E"],
};

const generator = new Diagrammer(); // create an instance of Diagrammer
var svg = generator.builder(chordDiagram, instrument); // build the svg
document.body.appendChild(svg); // add the svg in the html content (here the body)

A ChordDiagram is defined by:

  • frets (array of numbers). Use 0 for open strings and -1 for muted strings. Frets must be relative to the base-fret.
  • fingers (array of numbers). Use 0 for no finger. The fingers array length must match the frets array length. The fingers are optional
  • base-fret (number)

Customization

You can customize the diagram by changing the default settings.

For example:

builder.settings.dot.radius = 5; // change the dot radius
builder.settings.neck.lineWidth = 0.8; //change the line width of the neck

Here is all the available settings:

  • stringSpace
  • fretSpace
  • fontFamily
  • fingering:
    • color
    • margin
    • size
    • visible
  • dot:
    • radius
    • borderWith
    • fillColor
    • strokeColor
    • openStringRadius
  • neck
    • useRoman
    • color
    • nut:
      • color
      • visible
      • width
    • stringName:
      • color
      • size
      • margin
      • visible
    • grid:
      • color
      • width
      • visible
    • baseFret:
      • color
      • size
      • margin
      • visible
    • stringInfo:
      • color
      • size
      • margin
      • visible

Demo

  1. Clone
  2. Install dependencies:
$ npm i
  1. Run in dev mode:
$ npm run start

Open a browser and navigate to http://localhost:8082/ to load the demo.

Contributing

This project welcomes contributions of all types. If you find any bug or want some new features, please feel free to create an issue or submit a pull request.

Join the community and chat with us on Discord

License

MIT License

chord-diagrammer's People

Contributors

chordproject avatar edwinzap avatar jrmora avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

chord-diagrammer's Issues

Add styling settings

Remove the style.css file and add these styling in the settings class.
We should maybe refactor the Settings class to be cleaner and user-friendly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.