Class: VectorSalad::StandardShapes::Square
- Inherits:
-
Rect
- Object
- BasicShape
- Rect
- VectorSalad::StandardShapes::Square
- Defined in:
- lib/vector_salad/standard_shapes/square.rb,
lib/vector_salad/exporters/svg_exporter.rb
Overview
Square shape with equal width and height.
Instance Attribute Summary
Attributes inherited from Rect
Attributes inherited from BasicShape
Instance Method Summary collapse
-
#initialize(size, **options) ⇒ Square
constructor
A new instance of Square.
-
#to_svg ⇒ Object
Export the shape to an svg string.
Methods inherited from Rect
Methods included from Mixins::At
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
Constructor Details
#initialize(size, **options) ⇒ Square
Returns a new instance of Square.
13 14 15 16 |
# File 'lib/vector_salad/standard_shapes/square.rb', line 13 def initialize(size, **) super(size, size, **) self end |
Instance Method Details
#to_svg ⇒ Object
Export the shape to an svg string
122 123 124 125 126 127 |
# File 'lib/vector_salad/exporters/svg_exporter.rb', line 122 def to_svg svg = "<rect x=\"#{at[0]}\" y=\"#{at[1]}\"" svg << " width=\"#{size}\" height=\"#{size}\"" svg << VectorSalad::Exporters::SvgExporter.() svg << "/>" end |