Class: VectorSalad::StandardShapes::Square
- Inherits:
-
BasicShape
- Object
- BasicShape
- VectorSalad::StandardShapes::Square
- Includes:
- Mixins::At
- Defined in:
- lib/vector_salad/exporters/svg_exporter.rb,
lib/vector_salad/standard_shapes/square.rb
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Attributes inherited from BasicShape
Instance Method Summary collapse
-
#initialize(size, **options) ⇒ Square
constructor
A new instance of Square.
- #to_path ⇒ Object
- #to_svg ⇒ Object
Methods included from Mixins::At
Constructor Details
#initialize(size, **options) ⇒ Square
Returns a new instance of Square.
16 17 18 19 20 21 |
# File 'lib/vector_salad/standard_shapes/square.rb', line 16 def initialize(size, **) @size = size = @x, @y = 0, 0 self end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
9 10 11 |
# File 'lib/vector_salad/standard_shapes/square.rb', line 9 def size @size end |
Instance Method Details
#to_path ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/vector_salad/standard_shapes/square.rb', line 23 def to_path Path.new( N.n(@x, @y), N.n(@x, @y + @size), N.n(@x + @size, @y + @size), N.n(@x + @size, @y), ** ) end |
#to_svg ⇒ Object
109 110 111 112 113 114 |
# File 'lib/vector_salad/exporters/svg_exporter.rb', line 109 def to_svg svg = "<rect x=\"#{at[0]}\" y=\"#{at[1]}\"" svg << " width=\"#{size}\" height=\"#{size}\"" svg << VectorSalad::Exporters::SvgExporter.() svg << '/>' end |