Class: Clef::Layout::BeamLayout
- Inherits:
-
Object
- Object
- Clef::Layout::BeamLayout
- Defined in:
- lib/clef/layout/beam_layout.rb
Class Method Summary collapse
- .auto_beam(notes, time_signature) ⇒ Array<Array<Clef::Core::Note>>
- .compute(beam_group, _clef, _spacing) ⇒ Hash
Class Method Details
.auto_beam(notes, time_signature) ⇒ Array<Array<Clef::Core::Note>>
10 11 12 13 14 |
# File 'lib/clef/layout/beam_layout.rb', line 10 def auto_beam(notes, time_signature) return [] if notes.empty? notes.each_slice(group_size(time_signature)).to_a end |
.compute(beam_group, _clef, _spacing) ⇒ Hash
20 21 22 23 24 25 |
# File 'lib/clef/layout/beam_layout.rb', line 20 def compute(beam_group, _clef, _spacing) first_y = pitch_y(beam_group.first.pitch) last_y = pitch_y(beam_group.last.pitch) slope = ((last_y - first_y) / [beam_group.length - 1, 1].max).clamp(-0.5, 0.5) {start_y: first_y, end_y: first_y + slope * (beam_group.length - 1), slope: slope} end |