Class: Clef::Notation::Slur

Inherits:
Object
  • Object
show all
Defined in:
lib/clef/notation/slur.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_note, end_note) ⇒ Slur

Returns a new instance of Slur.

Parameters:



10
11
12
13
# File 'lib/clef/notation/slur.rb', line 10

def initialize(start_note, end_note)
  @start_note = start_note
  @end_note = end_note
end

Instance Attribute Details

#end_noteObject (readonly)

Returns the value of attribute end_note.



6
7
8
# File 'lib/clef/notation/slur.rb', line 6

def end_note
  @end_note
end

#start_noteObject (readonly)

Returns the value of attribute start_note.



6
7
8
# File 'lib/clef/notation/slur.rb', line 6

def start_note
  @start_note
end

Instance Method Details

#control_points(start_point, end_point) ⇒ Array<Array<Float>>

Parameters:

  • start_point (Array<Float>)
  • end_point (Array<Float>)

Returns:

  • (Array<Array<Float>>)


18
19
20
21
22
23
24
25
# File 'lib/clef/notation/slur.rb', line 18

def control_points(start_point, end_point)
  midpoint_x = (start_point[0] + end_point[0]) / 2.0
  lift = [((end_point[0] - start_point[0]).abs / 4.0), 6.0].max
  [
    [midpoint_x - 8, start_point[1] - lift],
    [midpoint_x + 8, end_point[1] - lift]
  ]
end