class Draught::Corner::Rounded

Attributes

incoming[R]
outgoing[R]
radius[R]

Public Class Methods

join(args) click to toggle source
# File lib/draught/corner.rb, line 26
def self.join(args)
  new(args).joined
end
new(args) click to toggle source
# File lib/draught/corner.rb, line 32
def initialize(args)
  @radius = args.fetch(:radius)
  @incoming = args.fetch(:incoming)
  @outgoing = args.fetch(:outgoing)
end

Public Instance Methods

corner_arc_path() click to toggle source
# File lib/draught/corner.rb, line 80
def corner_arc_path
  ArcBuilder.radians(angle: join_angles.arc_sweep, radius: radius, starting_angle: starting_angle).path
end
distance_to_tangent() click to toggle source
# File lib/draught/corner.rb, line 72
def distance_to_tangent
  @distance_to_tangent ||= join_angles.tangent_distance(radius)
end
incoming_before_final_segment() click to toggle source
# File lib/draught/corner.rb, line 48
def incoming_before_final_segment
  incoming[0..-2]
end
incoming_final_segment() click to toggle source
# File lib/draught/corner.rb, line 52
def incoming_final_segment
  incoming_line.extend(by: -distance_to_tangent)
end
incoming_line() click to toggle source
# File lib/draught/corner.rb, line 56
def incoming_line
  Line.from_path(incoming[-2,2])
end
join_angles() click to toggle source
# File lib/draught/corner.rb, line 76
def join_angles
  @join_angles ||= JoinAngles.new(incoming_line, outgoing_line)
end
joined() click to toggle source
# File lib/draught/corner.rb, line 38
def joined
  PathBuilder.connect(
    incoming_before_final_segment,
    incoming_final_segment,
    corner_arc_path,
    outgoing_first_segment,
    outgoing_after_first_segment
  )
end
outgoing_after_first_segment() click to toggle source
# File lib/draught/corner.rb, line 68
def outgoing_after_first_segment
  outgoing[1..-1]
end
outgoing_first_segment() click to toggle source
# File lib/draught/corner.rb, line 60
def outgoing_first_segment
  outgoing_line.extend(by: -distance_to_tangent, at: :start)
end
outgoing_line() click to toggle source
# File lib/draught/corner.rb, line 64
def outgoing_line
  Line.from_path(outgoing[0..1])
end
starting_angle() click to toggle source
# File lib/draught/corner.rb, line 84
def starting_angle
  incoming_line.radians - (Math::PI / 2)
end