Class: Sunniesnow::Tools::SvgPath::CubicBezier
- Inherits:
-
PathSegment
- Object
- PathSegment
- Sunniesnow::Tools::SvgPath::CubicBezier
- Includes:
- Curve
- Defined in:
- lib/sscharter/tools/svg_path.rb
Instance Attribute Summary collapse
- #begin ⇒ Vector2D readonly
- #control1 ⇒ Vector2D readonly
- #control2 ⇒ Vector2D readonly
- #end ⇒ Vector2D readonly
Instance Method Summary collapse
- #at(t) ⇒ Vector2D
-
#initialize(begin_point, control_point1, control_point2, end_point, segments: 16) ⇒ CubicBezier
constructor
A new instance of CubicBezier.
Methods included from Curve
Methods inherited from PathSegment
Constructor Details
#initialize(begin_point, control_point1, control_point2, end_point, segments: 16) ⇒ CubicBezier
Returns a new instance of CubicBezier.
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
#begin ⇒ Vector2D (readonly)
209 210 211 |
# File 'lib/sscharter/tools/svg_path.rb', line 209 def begin @begin end |
#control1 ⇒ Vector2D (readonly)
212 213 214 |
# File 'lib/sscharter/tools/svg_path.rb', line 212 def control1 @control1 end |
#control2 ⇒ Vector2D (readonly)
215 216 217 |
# File 'lib/sscharter/tools/svg_path.rb', line 215 def control2 @control2 end |
#end ⇒ Vector2D (readonly)
218 219 220 |
# File 'lib/sscharter/tools/svg_path.rb', line 218 def end @end end |
Instance Method Details
#at(t) ⇒ Vector2D
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 |