Class: Sunniesnow::Tools::SvgPath::CubicBezier

Inherits:
PathSegment
  • Object
show all
Includes:
Curve
Defined in:
lib/sscharter/tools/svg_path.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Curve

#at_length, #length

Methods inherited from PathSegment

#at_length, #length

Constructor Details

#initialize(begin_point, control_point1, control_point2, end_point, segments: 16) ⇒ CubicBezier

Returns a new instance of CubicBezier.

Parameters:



225
226
227
228
229
230
231
# File 'lib/sscharter/tools/svg_path.rb', line 225

def initialize begin_point, control_point1, control_point2, end_point, segments: 16
	@begin = begin_point
	@control1 = control_point1
	@control2 = control_point2
	@end = end_point
	make_segments segments
end

Instance Attribute Details

#beginVector2D (readonly)

Returns:



209
210
211
# File 'lib/sscharter/tools/svg_path.rb', line 209

def begin
  @begin
end

#control1Vector2D (readonly)

Returns:



212
213
214
# File 'lib/sscharter/tools/svg_path.rb', line 212

def control1
  @control1
end

#control2Vector2D (readonly)

Returns:



215
216
217
# File 'lib/sscharter/tools/svg_path.rb', line 215

def control2
  @control2
end

#endVector2D (readonly)

Returns:



218
219
220
# File 'lib/sscharter/tools/svg_path.rb', line 218

def end
  @end
end

Instance Method Details

#at(t) ⇒ Vector2D

Parameters:

  • t (Float)

Returns:



235
236
237
# File 'lib/sscharter/tools/svg_path.rb', line 235

def at t
	@begin*(1-t)**3 + @control1*(3*(1-t)**2*t) + @control2*(3*(1-t)*t**2) + @end*t**3
end