outro_rails 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/views/outro_rails/instruments/_guitar_figure.html.erb +5 -3
- data/app/views/outro_rails/instruments/_guitar_midi.html.erb +14 -6
- data/app/views/outro_rails/instruments/_piano_figure.html.erb +17 -10
- data/app/views/outro_rails/instruments/_piano_midi.html.erb +14 -6
- data/lib/outro_rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: faefc647f0e0140abbf35ca6c154c680f4b9288521391aed584eae48cb2657fe
|
|
4
|
+
data.tar.gz: 6801a967992044421351c38b537c66645a496c2f362034bcc36dd4778e9999c1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6ad7f179486fce333d763331c5a6b8bb2123aba871554255a93da7ffacd667cc8783fdec510121859028ca298bccdd0059a9b61a33c7e3e0a09eff9d46e2fc08
|
|
7
|
+
data.tar.gz: 75ab968c2ecdfcb471e26bbdbead2a2ca59180576106abecc8d0545e2c0d16432474683c68e31f1f2473ce7e6ab8a7434d776573c6b96ff7fb70ffe2d2ed5c30
|
|
@@ -36,12 +36,14 @@
|
|
|
36
36
|
highlight_frets = guitar_positions(
|
|
37
37
|
Array(local_assigns.fetch(:highlight_frets, [])).select(&complete)
|
|
38
38
|
)
|
|
39
|
-
highlight_color = local_assigns.fetch(:highlight_color,
|
|
39
|
+
highlight_color = local_assigns.fetch(:highlight_color,
|
|
40
|
+
"var(--outro-accent, #2f6bed)")
|
|
40
41
|
root_frets = guitar_positions(
|
|
41
42
|
Array(local_assigns.fetch(:root_frets, [])).select(&complete)
|
|
42
43
|
)
|
|
43
44
|
highlight_frets |= root_frets
|
|
44
|
-
root_color = local_assigns.fetch(:root_color,
|
|
45
|
+
root_color = local_assigns.fetch(:root_color,
|
|
46
|
+
"var(--outro-root, #d1495b)")
|
|
45
47
|
prefer = local_assigns.fetch(:prefer, "sharps").to_sym
|
|
46
48
|
|
|
47
49
|
open_midis = guitar_open_midis(tuning) # { 1 => 64, ..., 6 => 40 }
|
|
@@ -130,7 +132,7 @@
|
|
|
130
132
|
<% next unless fret.positive? && fret >= row_start %>
|
|
131
133
|
<% root = roots.include?([string, fret]) %>
|
|
132
134
|
<circle cx="<%= col_x.call(string) %>" cy="<%= row_y.call(fret) %>"
|
|
133
|
-
r="4.4"
|
|
135
|
+
r="4.4" style="fill: <%= root ? root_color : highlight_color %>" />
|
|
134
136
|
<% end %>
|
|
135
137
|
|
|
136
138
|
<%# sounded note names under the box %>
|
|
@@ -10,12 +10,14 @@
|
|
|
10
10
|
1 (highest pitch) to 6 (lowest). Accepts [string, fret]
|
|
11
11
|
pairs or "string:fret" strings, e.g.
|
|
12
12
|
[[5, 3], [4, 2], [3, 0], [2, 1], [1, 0]] (open C major)
|
|
13
|
-
highlight_color: any CSS color for the dots
|
|
13
|
+
highlight_color: any CSS color for the dots. Omit to inherit
|
|
14
|
+
--outro-accent from the host app (see note below).
|
|
14
15
|
root_frets: subset of positions to mark as roots with a distinct
|
|
15
16
|
color, same formats as highlight_frets (default []).
|
|
16
17
|
Root positions should also be included in
|
|
17
18
|
highlight_frets so playback covers them.
|
|
18
|
-
root_color: any CSS color for root dots
|
|
19
|
+
root_color: any CSS color for root dots. Omit to inherit
|
|
20
|
+
--outro-root from the host app.
|
|
19
21
|
|
|
20
22
|
When highlight_frets is present, "Play Chord" strums all marked notes
|
|
21
23
|
(lowest first, slightly staggered like a downstroke) and "Play Notes"
|
|
@@ -29,11 +31,18 @@
|
|
|
29
31
|
default_tuning = OutroRails::InstrumentsHelper::GUITAR_STANDARD_TUNING
|
|
30
32
|
tuning = local_assigns.fetch(:tuning, default_tuning)
|
|
31
33
|
highlight_frets = guitar_positions(local_assigns.fetch(:highlight_frets, []))
|
|
32
|
-
highlight_color = local_assigns.fetch(:highlight_color, "#2f6bed")
|
|
33
34
|
root_frets = guitar_positions(local_assigns.fetch(:root_frets, []))
|
|
34
|
-
root_color = local_assigns.fetch(:root_color, "#d1495b")
|
|
35
35
|
prefer = local_assigns.fetch(:prefer, 'sharps')
|
|
36
36
|
|
|
37
|
+
# Only emit inline custom properties for colors the caller actually
|
|
38
|
+
# passed; the stylesheet owns the defaults.
|
|
39
|
+
highlight_color = local_assigns[:highlight_color].presence
|
|
40
|
+
root_color = local_assigns[:root_color].presence
|
|
41
|
+
color_vars = [
|
|
42
|
+
("--outro-guitar-highlight: #{highlight_color};" if highlight_color),
|
|
43
|
+
("--outro-guitar-root: #{root_color};" if root_color)
|
|
44
|
+
].compact.join(" ").presence
|
|
45
|
+
|
|
37
46
|
start_fret, end_fret = end_fret, start_fret if start_fret > end_fret
|
|
38
47
|
guitar = OutroRails::Instruments::Guitar
|
|
39
48
|
fret_range = guitar::MIN_FRET..guitar::MAX_FRET
|
|
@@ -60,8 +69,7 @@
|
|
|
60
69
|
|
|
61
70
|
<div class="outro-guitar"
|
|
62
71
|
data-outro-guitar
|
|
63
|
-
style
|
|
64
|
-
--outro-guitar-root: <%= root_color %>;">
|
|
72
|
+
<%= tag.attributes(style: color_vars) %>>
|
|
65
73
|
<div>
|
|
66
74
|
<div class="outro-guitar__board"
|
|
67
75
|
role="group"
|
|
@@ -18,9 +18,11 @@
|
|
|
18
18
|
start_note = local_assigns.fetch(:start_note, nil).presence || "C3"
|
|
19
19
|
end_note = local_assigns.fetch(:end_note, nil).presence || "C5"
|
|
20
20
|
highlight_keys = Array(local_assigns.fetch(:highlight_keys, []))
|
|
21
|
-
highlight_color = local_assigns.fetch(:highlight_color,
|
|
21
|
+
highlight_color = local_assigns.fetch(:highlight_color,
|
|
22
|
+
"var(--outro-accent, #2f6bed)")
|
|
22
23
|
root_keys = Array(local_assigns.fetch(:root_keys, []))
|
|
23
|
-
root_color = local_assigns.fetch(:root_color,
|
|
24
|
+
root_color = local_assigns.fetch(:root_color,
|
|
25
|
+
"var(--outro-root, #d1495b)")
|
|
24
26
|
prefer = local_assigns.fetch(:prefer, "sharps").to_sym
|
|
25
27
|
|
|
26
28
|
keys = piano_keys_between(start_note, end_note, prefer: prefer)
|
|
@@ -29,6 +31,8 @@
|
|
|
29
31
|
|
|
30
32
|
white_w, white_h = 14, 46 # viewBox units
|
|
31
33
|
black_w, black_h = 8.5, 28
|
|
34
|
+
stroke_w = 0.75
|
|
35
|
+
pad = stroke_w / 2.0
|
|
32
36
|
|
|
33
37
|
whites = []
|
|
34
38
|
blacks = []
|
|
@@ -44,8 +48,6 @@
|
|
|
44
48
|
end
|
|
45
49
|
end
|
|
46
50
|
|
|
47
|
-
width = [white_index, 1].max * white_w
|
|
48
|
-
|
|
49
51
|
fill_for = lambda do |key|
|
|
50
52
|
if root_midis.include?(key[:midi]) then root_color
|
|
51
53
|
elsif highlighted_midis.include?(key[:midi]) then highlight_color
|
|
@@ -60,23 +62,28 @@
|
|
|
60
62
|
else
|
|
61
63
|
"Piano keyboard from #{start_note} to #{end_note}"
|
|
62
64
|
end
|
|
65
|
+
|
|
66
|
+
width = [white_index, 1].max * white_w
|
|
67
|
+
vb_w = width + (pad * 2)
|
|
68
|
+
vb_h = white_h + (pad * 2)
|
|
63
69
|
%>
|
|
64
70
|
|
|
65
71
|
<svg class="outro-figure__svg outro-figure__svg--piano"
|
|
66
|
-
viewBox="
|
|
67
|
-
width="<%= (
|
|
72
|
+
viewBox="<%= -pad %> <%= -pad %> <%= vb_w %> <%= vb_h %>"
|
|
73
|
+
width="<%= (vb_w * 0.9).round %>"
|
|
74
|
+
height="<%= (vb_h * 0.9).round %>"
|
|
68
75
|
role="img"
|
|
69
76
|
aria-label="<%= label %>">
|
|
70
77
|
<% whites.each do |key| %>
|
|
71
78
|
<rect x="<%= key[:x] %>" y="0"
|
|
72
79
|
width="<%= white_w %>" height="<%= white_h %>"
|
|
73
|
-
rx="1.5"
|
|
74
|
-
stroke="#444444" stroke-width="
|
|
80
|
+
rx="1.5" style="fill: <%= fill_for.call(key) %>"
|
|
81
|
+
stroke="#444444" stroke-width="<%= stroke_w %>" />
|
|
75
82
|
<% end %>
|
|
76
83
|
<% blacks.each do |key| %>
|
|
77
84
|
<rect x="<%= key[:x] %>" y="0"
|
|
78
85
|
width="<%= black_w %>" height="<%= black_h %>"
|
|
79
|
-
rx="1.5"
|
|
80
|
-
stroke="#111111" stroke-width="
|
|
86
|
+
rx="1.5" style="fill: <%= fill_for.call(key) %>"
|
|
87
|
+
stroke="#111111" stroke-width="<%= stroke_w %>" />
|
|
81
88
|
<% end %>
|
|
82
89
|
</svg>
|
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
end_note: last key, e.g. "C5" (default "C5")
|
|
7
7
|
highlight_keys: array of note names to highlight,
|
|
8
8
|
e.g. %w[C4 E4 G4] (default [])
|
|
9
|
-
highlight_color: any CSS color for highlighted keys
|
|
9
|
+
highlight_color: any CSS color for highlighted keys. Omit to inherit
|
|
10
|
+
--outro-accent from the host app (see note below).
|
|
10
11
|
root_keys: subset of keys to mark as roots with a distinct color,
|
|
11
12
|
e.g. %w[C4 C5] (default []). Root keys should also be
|
|
12
13
|
included in highlight_keys so playback covers them.
|
|
13
|
-
root_color: any CSS color for root keys
|
|
14
|
+
root_color: any CSS color for root keys. Omit to inherit
|
|
15
|
+
--outro-root from the host app.
|
|
14
16
|
|
|
15
17
|
When highlight_keys is present, "Play Chord" plays all highlighted notes
|
|
16
18
|
at once and "Play Notes" plays them one at a time (low to high).
|
|
@@ -21,11 +23,18 @@
|
|
|
21
23
|
start_note = local_assigns.fetch(:start_note, "C3")
|
|
22
24
|
end_note = local_assigns.fetch(:end_note, "C5")
|
|
23
25
|
highlight_keys = Array(local_assigns.fetch(:highlight_keys, []))
|
|
24
|
-
highlight_color = local_assigns.fetch(:highlight_color, "#2f6bed")
|
|
25
26
|
root_keys = Array(local_assigns.fetch(:root_keys, []))
|
|
26
|
-
root_color = local_assigns.fetch(:root_color, "#d1495b")
|
|
27
27
|
prefer = local_assigns.fetch(:prefer, 'sharps').to_sym
|
|
28
28
|
|
|
29
|
+
# Only emit inline custom properties for colors the caller actually
|
|
30
|
+
# passed; the stylesheet owns the defaults.
|
|
31
|
+
highlight_color = local_assigns[:highlight_color].presence
|
|
32
|
+
root_color = local_assigns[:root_color].presence
|
|
33
|
+
color_vars = [
|
|
34
|
+
("--outro-piano-highlight: #{highlight_color};" if highlight_color),
|
|
35
|
+
("--outro-piano-root: #{root_color};" if root_color)
|
|
36
|
+
].compact.join(" ").presence
|
|
37
|
+
|
|
29
38
|
keys = piano_keys_between(start_note, end_note, prefer: prefer)
|
|
30
39
|
highlighted_midis = highlight_keys.map { |n| note_to_midi(n) }
|
|
31
40
|
root_midis = root_keys.map { |n| note_to_midi(n) }
|
|
@@ -35,8 +44,7 @@
|
|
|
35
44
|
|
|
36
45
|
<div class="outro-piano"
|
|
37
46
|
data-outro-piano
|
|
38
|
-
style
|
|
39
|
-
--outro-piano-root: <%= root_color %>;">
|
|
47
|
+
<%= tag.attributes(style: color_vars) %>>
|
|
40
48
|
<div class="outro-piano__keys" role="group"
|
|
41
49
|
aria-label="<%= keys_label %>">
|
|
42
50
|
<% keys.each do |key| %>
|
data/lib/outro_rails/version.rb
CHANGED