chord_diagrams 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f917ed924b695bd82eaa9dc5f5253ce86136de34050c372166dd2e958952244e
4
- data.tar.gz: 467fc8f53c37e965c7f137c6e4749545956b2477f467dcdb730ea3d8a7a93957
3
+ metadata.gz: 135386bd1af18078290e62fb0bc3792ddb07ff973717b4148ebead48e017bd2b
4
+ data.tar.gz: 6f2f12911358baae68cf0299a76348439619e757d428c8ccbccf0ad7bae0c332
5
5
  SHA512:
6
- metadata.gz: 29be58789b8c63d8ba6a19b1c84cf0c3d03b557ac48c234c2abc3f4e2f68ed2345f464037a89d4b93f4f172e3f589f82bfb4a84cbe67bc95ab49943a25fa7199
7
- data.tar.gz: 5317272f9c36b0856e92d47cc667171b8849cd38b82fcb9cd4b20b48515eac99783756ea8ba55b71106f430d42c6e2ec7894c3a66eeac037deb10739984f3ae4
6
+ metadata.gz: 317c76f9d1f67d9f0048fbb536c241ef25cc2e4a78bde7fe5d80afa2883d437ded28cb7b9ac1ac99b5835154eb3d654aa2b10d2e6b3b98e8af954c20280ecca2
7
+ data.tar.gz: 315b30e1547f28f0d104879e6bac1e2aeb218738f32fe5bff1de5b5988563ed30de3c1d51c39f03235778baa268dee12c49b0b22359b18db1792815426152075
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
 
13
13
  .idea
14
14
  Gemfile.lock
15
+ sheet.html
data/Rakefile CHANGED
@@ -4,3 +4,16 @@ require 'rspec/core/rake_task'
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  task default: :spec
7
+
8
+ task :sheet do
9
+ require 'chord_diagrams'
10
+
11
+ html = ""
12
+
13
+ ChordDiagrams::FINGERINGS.each do |name, fingering|
14
+ diagram = ChordDiagrams.chord_svg(name, fingering)
15
+ html << diagram
16
+ end
17
+
18
+ File.open('sheet.html', 'w') { |file| file.write(html) }
19
+ end
@@ -39,4 +39,5 @@ Gem::Specification.new do |spec|
39
39
  spec.add_development_dependency 'bundler', '~> 2.0'
40
40
  spec.add_development_dependency 'rake', '~> 10.0'
41
41
  spec.add_development_dependency 'rspec', '~> 3.0'
42
+ spec.add_development_dependency 'nokogiri'
42
43
  end
@@ -43,18 +43,12 @@ module ChordDiagrams
43
43
  def draw_chord_diagram(fingerings, svg)
44
44
  fingerings = fingerings.split('')
45
45
 
46
- lowest_fret = fingerings.min
46
+ lowest_fret = fingerings.reject{ |fret| fret.to_i < 1 }.min
47
47
 
48
48
  if lowest_fret.to_i > 2
49
- svg.text lowest_fret, x: 35, y: 96, text_anchor: :end, style: { font_size: 20 }
50
-
51
- fingerings = fingerings.map do |fingering|
52
- if fingering != 'x'
53
- fingering.to_i - lowest_fret.to_i + 1
54
- else
55
- fingering
56
- end
57
- end
49
+ svg.text lowest_fret, id: 'fretNumber', x: 35, y: 96, text_anchor: :end, style: { font_size: 20 }
50
+
51
+ fingerings = shift_fingerings(fingerings, lowest_fret)
58
52
  else
59
53
  draw_nut(svg)
60
54
  end
@@ -73,14 +67,14 @@ module ChordDiagrams
73
67
  end
74
68
 
75
69
  def draw_name(name, svg)
76
- svg.text name, x: 100, y: 40, text_anchor: :middle, style: {
70
+ svg.text name, id: 'chordName', x: 100, y: 40, text_anchor: :middle, style: {
77
71
  font_size: 36,
78
72
  font_weight: :bold
79
73
  }
80
74
  end
81
75
 
82
76
  def draw_nut(svg)
83
- svg.line x1: 49, y1: 77, x2: 151, y2: 77, style: {
77
+ svg.line id: 'nut', x1: 49, y1: 77, x2: 151, y2: 77, style: {
84
78
  stroke: :black,
85
79
  stroke_width: 8
86
80
  }
@@ -114,5 +108,17 @@ module ChordDiagrams
114
108
  svg.line x1: 50, y1: y, x2: 150, y2: y, style: LINE_STYLE
115
109
  end
116
110
  end
111
+
112
+ private
113
+
114
+ def shift_fingerings(fingerings, lowest_fret)
115
+ fingerings.map do |fingering|
116
+ if fingering != 'x' && fingering != '0'
117
+ fingering.to_i - lowest_fret.to_i + 1
118
+ else
119
+ fingering
120
+ end
121
+ end
122
+ end
117
123
  end
118
124
  end
@@ -6,7 +6,7 @@ module ChordDiagrams
6
6
  'Bb': 'x13331',
7
7
  'C': 'x32010',
8
8
  'C#': 'x46664',
9
- 'D': 'x00232',
9
+ 'D': 'xx0232',
10
10
  'D#': 'x68886',
11
11
  'E': '022100',
12
12
  'Eb': 'x68886',
@@ -21,6 +21,7 @@ module ChordDiagrams
21
21
  'D#5': 'x688xx',
22
22
 
23
23
  # Six Chords
24
+ 'C6': 'x32210',
24
25
  'D6': 'xx0202',
25
26
  'E6': '022120',
26
27
  'G6': '320000',
@@ -44,6 +45,10 @@ module ChordDiagrams
44
45
  'EM7': 'xx2444',
45
46
  'FM7': '132211',
46
47
 
48
+ # Major 9th Chords
49
+ 'Cadd9': 'x32033',
50
+ 'Fadd9': 'xx3213',
51
+
47
52
  # Major Suspended 2nd Chords
48
53
  'Dsus2': 'xx0230',
49
54
  'Asus2': 'x02200',
@@ -81,16 +86,16 @@ module ChordDiagrams
81
86
  'F#m7': '242222',
82
87
  'Gm7': '353333',
83
88
 
89
+ # Minor Ninth Chotds
90
+ 'Am9': "x05557",
91
+
84
92
  # Minor Eleventh Chords
85
93
  'Bm11': 'x20220',
86
94
  'F#m11': '202200',
87
95
 
88
- # Major 9th Chords
89
- 'Cadd9': 'x32033',
90
-
91
96
  # Major Chords with Bass Notes
92
- 'A/C#': '002220',
93
- 'A/E': '04222x',
97
+ 'A/C#': '042220',
98
+ 'A/E': '00222x',
94
99
  'A/F#': '202220',
95
100
  'Bb/A': 'x00331',
96
101
  'C/B': 'x22010',
@@ -105,6 +110,9 @@ module ChordDiagrams
105
110
  'D7/F#': '200212',
106
111
  'G7/F': '123003',
107
112
 
113
+ # Ninth Chords with Bass Notes
114
+ 'D9/F#': '2x0210',
115
+
108
116
  # Minor Chords with Bass Notes
109
117
  'Am/D': 'xx0210',
110
118
  'Am/G': '302210',
@@ -1,3 +1,3 @@
1
1
  module ChordDiagrams
2
- VERSION = '0.0.4'.freeze
2
+ VERSION = '0.0.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chord_diagrams
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Kelly
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-05 00:00:00.000000000 Z
11
+ date: 2019-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: victor
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: Generate Chord Diagrams for Guitar
70
84
  email:
71
85
  - bkelly@carbonfive.com