Class: Sevgi::Geometry::Square
- Defined in:
- lib/sevgi/geometry/elements/rect.rb
Overview
Rectangle with equal width and height. Use Rect#width or Rect#height for its side length; inherited Element::Lined#length returns the complete path length.
Instance Attribute Summary
Attributes inherited from Rect
#A, #AB, #B, #BC, #C, #CD, #D, #DA
Class Method Summary collapse
-
.[](length, position: Origin) ⇒ Sevgi::Geometry::Square
Builds a square from side length and top-left position.
-
.from_corners(top_left, bottom_right) ⇒ Sevgi::Geometry::Square
Builds a square from two opposite corners.
-
.from_size(length, position: Origin) ⇒ Sevgi::Geometry::Square
Builds a square from side length and top-left position.
Methods inherited from Rect
#bottom, #bottom_left, #bottom_right, call, #height, #left, #perimeter, #right, #top, #top_left, #top_right, #width
Class Method Details
.[](length, position: Origin) ⇒ Sevgi::Geometry::Square
Builds a square from side length and top-left position.
235 |
# File 'lib/sevgi/geometry/elements/rect.rb', line 235 def self.[](length, position: Origin) = construct(length, length, position:) |
.from_corners(top_left, bottom_right) ⇒ Sevgi::Geometry::Square
Builds a square from two opposite corners.
242 |
# File 'lib/sevgi/geometry/elements/rect.rb', line 242 def self.from_corners(top_left, bottom_right) = call(top_left, bottom_right) |
.from_size(length, position: Origin) ⇒ Sevgi::Geometry::Square
Builds a square from side length and top-left position.
249 |
# File 'lib/sevgi/geometry/elements/rect.rb', line 249 def self.from_size(length, position: Origin) = self[length, position:] |