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
Attributes inherited from BasicShape
Instance Method Summary collapse
-
#initialize(size, **options) ⇒ Heart
constructor
A new instance of Heart.
-
#to_path ⇒ Object
Convert the shape to a path.
Methods inherited from BasicShape
#flip, #flip_x, #flip_y, #jitter, #move, #rotate, #scale, #to_a, #to_bezier_path, #to_cubic_path, #to_multi_path, #to_simple_path, #to_svg
Constructor Details
#initialize(size, **options) ⇒ Heart
Returns a new instance of Heart.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/vector_salad/standard_shapes/heart.rb', line 9 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 Method Details
#to_path ⇒ Object
Convert the shape to a path
28 29 30 |
# File 'lib/vector_salad/standard_shapes/heart.rb', line 28 def to_path @shape end |