Class: Clef::Notation::Tie

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_note, end_note) ⇒ Tie

Returns a new instance of Tie.

Parameters:

Raises:

  • (ArgumentError)


10
11
12
13
14
15
# File 'lib/clef/notation/tie.rb', line 10

def initialize(start_note, end_note)
  raise ArgumentError, "tie requires notes with same pitch" unless start_note.pitch.enharmonic?(end_note.pitch)

  @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/tie.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/tie.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>>)


20
21
22
23
24
25
26
27
# File 'lib/clef/notation/tie.rb', line 20

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 / 8.0), 3.0].max
  [
    [midpoint_x - 6, start_point[1] - lift],
    [midpoint_x + 6, end_point[1] - lift]
  ]
end