class DemCurves::Path
Attributes
control_points[R]
path_elements[R]
path_points[R]
Public Class Methods
new(point)
click to toggle source
# File lib/core/path.rb, line 8 def initialize(point) @path_elements = [] @start_point = ControlPoint[*point] @end_point = @start_point @path_points = to_a @control_points = [@start_point] end
Public Instance Methods
add_bezier(start_handle, end_handle, end_point, tangent_lock=true)
click to toggle source
# File lib/core/path.rb, line 18 def add_bezier(start_handle, end_handle, end_point, tangent_lock=true) new_bezier = CubicBezier.new( @end_point, ControlPoint[*start_handle], ControlPoint[*end_handle], ControlPoint[*end_point]) if tangent_lock and @path_elements.last start_length = (new_bezier[:start_handle].loc - @end_point.loc).r last_element = @path_elements.last case last_element when CubicBezier LineUpConstraint.new @end_point, last_element[:end_handle], new_bezier[:start_handle] when Line LineUpConstraint.new @end_point, last_element[:center], new_bezier[:start_handle], morror_distance=false, follow=:p0 end end @end_point = new_bezier[:end] @path_elements << new_bezier @path_points = to_a @control_points += new_bezier.control_points.values[1..-1] end
add_line(end_point, tangent_lock=true)
click to toggle source
# File lib/core/path.rb, line 44 def add_line(end_point, tangent_lock=true) center_point = ControlPoint[*(@end_point.loc + (Vector[*end_point] - @end_point.loc) * 0.5)] new_line = Line.new @end_point, center_point, ControlPoint[*end_point] LineUpConstraint.new center_point, new_line[:end], @end_point if tangent_lock and @path_elements.last last_element = @path_elements.last case last_element when CubicBezier LineUpConstraint.new @end_point, last_element[:end_handle], new_line[:end], morror_distance=false, follow=:p1 when Line @end_point.move_to end_point return end end @end_point = new_line[:end] @path_elements << new_line @path_points = to_a @control_points += new_line.control_points.values[1..-1] end
each() { |loc| ... }
click to toggle source
# File lib/core/path.rb, line 68 def each yield @start_point.loc @path_elements.each do |path_element| (1..path_element.path_points.size-1).each do |index| yield path_element.path_points[index] end end end
get_guides()
click to toggle source
# File lib/core/path.rb, line 81 def get_guides @path_elements.inject([]) do |mem, element| mem += element.get_guides end end
size()
click to toggle source
# File lib/core/path.rb, line 77 def size return @path_points.size end