Class: FlameChannelParser::Parser2012::ModernKey

Inherits:
Struct
  • Object
show all
Defined in:
lib/parser_2012.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) break_slope

Returns the value of attribute break_slope

Returns:

  • (Object)

    the current value of break_slope



7
8
9
# File 'lib/parser_2012.rb', line 7

def break_slope
  @break_slope
end

- (Object) curve_mode

Returns the value of attribute curve_mode

Returns:

  • (Object)

    the current value of curve_mode



7
8
9
# File 'lib/parser_2012.rb', line 7

def curve_mode
  @curve_mode
end

- (Object) curve_order

Returns the value of attribute curve_order

Returns:

  • (Object)

    the current value of curve_order



7
8
9
# File 'lib/parser_2012.rb', line 7

def curve_order
  @curve_order
end

- (Object) frame

Returns the value of attribute frame

Returns:

  • (Object)

    the current value of frame



7
8
9
# File 'lib/parser_2012.rb', line 7

def frame
  @frame
end

- (Object) l_handle_x

Returns the value of attribute l_handle_x

Returns:

  • (Object)

    the current value of l_handle_x



7
8
9
# File 'lib/parser_2012.rb', line 7

def l_handle_x
  @l_handle_x
end

- (Object) l_handle_y

Returns the value of attribute l_handle_y

Returns:

  • (Object)

    the current value of l_handle_y



7
8
9
# File 'lib/parser_2012.rb', line 7

def l_handle_y
  @l_handle_y
end

- (Object) r_handle_x

Returns the value of attribute r_handle_x

Returns:

  • (Object)

    the current value of r_handle_x



7
8
9
# File 'lib/parser_2012.rb', line 7

def r_handle_x
  @r_handle_x
end

- (Object) r_handle_y

Returns the value of attribute r_handle_y

Returns:

  • (Object)

    the current value of r_handle_y



7
8
9
# File 'lib/parser_2012.rb', line 7

def r_handle_y
  @r_handle_y
end

- (Object) value

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



7
8
9
# File 'lib/parser_2012.rb', line 7

def value
  @value
end

Instance Method Details

- (Boolean) broken?

Returns:

  • (Boolean)


36
37
38
# File 'lib/parser_2012.rb', line 36

def broken?
  break_slope
end

- (Object) interpolation

Adapter for old interpolation



11
12
13
14
15
16
17
18
# File 'lib/parser_2012.rb', line 11

def interpolation
  return :constant if curve_order.to_s == "constant"
  return :hermite if curve_order.to_s == "cubic" && (curve_mode.to_s == "hermite" || curve_mode.to_s == "natural")
  return :bezier if curve_order.to_s == "cubic" && curve_mode.to_s == "bezier"
  return :linear if curve_order.to_s == "linear"
  
  raise "Cannot determine interpolation for #{self.inspect}"
end

- (Object) left_slope

Compute pre-212 slope which we use for interpolations



21
22
23
24
25
26
27
# File 'lib/parser_2012.rb', line 21

def left_slope
  return right_slope unless broken?
  
  dy = value - l_handle_y
  dx = l_handle_x - frame
  dy / dx  * -1
end

- (Object) right_slope

Compute pre-212 slope which we use for interpolations



30
31
32
33
34
# File 'lib/parser_2012.rb', line 30

def right_slope
  dy = value - r_handle_y
  dx = frame - r_handle_x
  dy / dx
end