Permalink
Browse files

Mil cosas mas

  • Loading branch information...
1 parent e45298a commit f26464aa7a7cb8764c4cbd4164d18b35fc62bc3f @choan committed Jul 17, 2011
Showing with 28 additions and 7 deletions.
  1. +19 −3 lib/fretboards/fretboard.rb
  2. +9 −4 lib/fretboards/renderers/svg.rb
@@ -29,9 +29,26 @@ def self.parse_simple(s)
end
def self.parse_verbose(s)
- "3/4 f3 i5, "
- require "pp"
fb = self.new
+ if s.start_with? "("
+ conf, s = *s.split(")")
+ s.strip!
+ conf = conf[1..-1]
+ conf_fragments = conf.split(/\s*,\s*/)
+ conf_fragments.each do |cf|
+ if cf.start_with? "frets:"
+ fst, fend = *cf.scan(/\d+/).map { |x| x.to_i }
+ fb.configure(:fret_start => fst, :fret_end => fend)
+ elsif cf.start_with? "label:"
+ fst, fend = *cf.scan(/\d+/).map { |x| x && x.to_i }
+ fb.label_fret(fst, fend || 0)
+ else
+ # unimplemented
+ end
+ end
+ require "pp"
+ pp conf_fragments
+ end
s = s.sub(/,\s?$/, "")
marks = s.split(/\s*,\s*/)
marks.each do |m|
@@ -48,7 +65,6 @@ def self.parse_verbose(s)
fb.mark params
end
fb
- # pp parts
end
def initialize(conf = {}, &block)
@@ -13,10 +13,14 @@ def function_symbol_to_s(sym)
:p5 => "5",
:maj3 => "3",
:root => "1",
- :b3 => "b3",
- :b5 => "b5",
- :b7 => "b7",
- :maj7 => 7,
+ :b3 => "♭3",
+ :b5 => "♭5",
+ :b7 => "♭7",
+ :maj7 => "7",
+ :p6 => "6",
+ :aug5 => "♯5",
+ :maj9 => "9",
+ :b9 => "♭9",
}[sym] || sym.to_s
end
@@ -55,6 +59,7 @@ def render(fretboard)
# Horizontal lines
# TODO accept any range of frets
(0..fretboard.fret_end).each do |fret|
+ # fret = fret - fretboard.fret_start
x1 = padding
x2 = canvas_width - padding
y = padding + fret * fret_spacing

0 comments on commit f26464a

Please sign in to comment.