Class: VectorSalad::StandardShapes::Heart
- Inherits:
-
BasicShape
- Object
- BasicShape
- VectorSalad::StandardShapes::Heart
- Defined in:
- lib/vector_salad/standard_shapes/heart.rb
Overview
Perfect heart shape.
Instance Attribute Summary (collapse)
-
- (Object) options
inherited
from BasicShape
Returns the value of attribute options.
Instance Method Summary (collapse)
-
- (Heart) initialize(size, **options)
constructor
Create a perfect heart.
-
- (Object) to_path
Convert the shape to a path.
Constructor Details
- (Heart) initialize(size, **options)
Create a perfect heart
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vector_salad/standard_shapes/heart.rb', line 11 def initialize(size, **) r = size / 4 # two circles next to each other r2 = Math.sqrt(2 * r**2) the_little_bit = r2 - r the_long_one = size + 2 * the_little_bit l = Math.sqrt(the_long_one**2 / 2) - r @shape = Union.new(**) do circle(r)[-r, 0] circle(r)[r, 0] difference do square(l)[-l / 2, -l / 2].rotate(45).move(0, r2 / 2) square(l * 2)[-l, -l * 2] end end self end |
Instance Attribute Details
- (Object) options Originally defined in class BasicShape
Returns the value of attribute options
Instance Method Details
- (Object) to_path
Convert the shape to a path
30 31 32 |
# File 'lib/vector_salad/standard_shapes/heart.rb', line 30 def to_path @shape end |