class Draught::Curve
An abstract representation of a curve in a pointlike fashion, in the way a CubicBezier
is pointlike
Attributes
point[R]
Public Class Methods
new(args = {})
click to toggle source
# File lib/draught/curve.rb, line 12 def initialize(args = {}) @point = args.fetch(:point) @cubic_beziers = args.fetch(:cubic_beziers).dup.freeze end
Public Instance Methods
==(other)
click to toggle source
# File lib/draught/curve.rb, line 33 def ==(other) other.point_type == point_type && other.point == point && other.as_cubic_beziers == as_cubic_beziers end
approximates?(other, delta)
click to toggle source
# File lib/draught/curve.rb, line 38 def approximates?(other, delta) other.point_type == point_type && point.approximates?(other.point, delta) && number_of_segments == other.number_of_segments && as_cubic_beziers.zip(other.as_cubic_beziers).all? { |a, b| a.approximates?(b, delta) } end
as_cubic_beziers()
click to toggle source
# File lib/draught/curve.rb, line 29 def as_cubic_beziers @cubic_beziers end
point_type()
click to toggle source
# File lib/draught/curve.rb, line 25 def point_type :curve end
transform(transformer)
click to toggle source
# File lib/draught/curve.rb, line 59 def transform(transformer) self.class.new({ point: @point.transform(transformer), cubic_beziers: @cubic_beziers.map { |c| c.transform(transformer) } }) end
translate(vector)
click to toggle source
# File lib/draught/curve.rb, line 52 def translate(vector) self.class.new({ point: @point.translate(vector), cubic_beziers: @cubic_beziers.map { |c| c.translate(vector) } }) end
x()
click to toggle source
# File lib/draught/curve.rb, line 17 def x @point.x end
y()
click to toggle source
# File lib/draught/curve.rb, line 21 def y @point.y end
Protected Instance Methods
number_of_segments()
click to toggle source
# File lib/draught/curve.rb, line 47 def number_of_segments @cubic_beziers.length end