Class: DYI::Shape::Path::QuadraticCurveCommand

Inherits:
CurveCommandBase show all
Defined in:
lib/dyi/shape/path.rb

Overview

Since:

  • 0.0.0

Direct Known Subclasses

ShorthandQuadraticCurveCommand

Instance Attribute Summary

Attributes inherited from CommandBase

#point, #preceding_command

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CurveCommandBase

commands, #initialize, #last_control_point, #to_concise_syntax_fragments

Methods inherited from CommandBase

#absolute?, absolute_commands, #initialize, #last_point, #preceding_point, #relative?, relative_commands, #start_point, #used_same_command?

Constructor Details

This class inherits a constructor from DYI::Shape::Path::CurveCommandBase

Class Method Details

.pt_cntObject

Since:

  • 0.0.0



913
914
915
# File 'lib/dyi/shape/path.rb', line 913

def pt_cnt
  2
end

Instance Method Details

#control_pointObject

Since:

  • 0.0.0



898
899
900
# File 'lib/dyi/shape/path.rb', line 898

def control_point
  @control_points[0]
end

#instructions_charObject

Since:

  • 0.0.0



908
909
910
# File 'lib/dyi/shape/path.rb', line 908

def instructions_char
  relative? ? 'q' : 'Q'
end

#preceding_control_pointObject

Since:

  • 0.0.0



890
891
892
893
894
895
896
# File 'lib/dyi/shape/path.rb', line 890

def preceding_control_point
  if preceding_command.is_a?(QuadraticCurveCommand)
    preceding_command.last_control_point
  else
    preceding_command.last_point
  end
end

#to_compatible_commands(preceding_command) ⇒ Object

Since:

  • 0.0.0



902
903
904
905
906
# File 'lib/dyi/shape/path.rb', line 902

def to_compatible_commands(preceding_command)
  ctrl_pt1 = relative? ? control_point * 2.0 / 3.0 : (preceding_point + control_point * 2.0) / 3.0
  ctrl_pt2 = (control_point * 2.0 + point) / 3.0
  CurveCommand.new(relative?, preceding_command, ctrl_pt1, ctrl_pt2, @point)
end