Class: Sevgi::Geometry::Element
- Inherits:
-
Object
- Object
- Sevgi::Geometry::Element
- Defined in:
- lib/sevgi/geometry/element.rb
Overview
Abstract base class for positioned geometry values.
Construct concrete shapes through their class factories. Element operations return new values, and #box supplies the axis-aligned bounds used by alignment and tiling helpers.
Direct Known Subclasses
Defined Under Namespace
Classes: Lined
Class Method Summary collapse
-
.lined(size = Undefined, open: false) ⇒ Class
Builds a lined element subclass.
Instance Method Summary collapse
-
#at(point = nil, dx: 0, dy: 0) ⇒ Sevgi::Geometry::Element
Returns a copy moved to a point and optional offset.
-
#box ⇒ Sevgi::Geometry::Rect
abstract
Returns the bounding rectangle.
-
#equations ⇒ Array<Sevgi::Geometry::Equation>
abstract
Returns equations that define the element boundary.
-
#ignorable?(precision: nil) ⇒ Boolean
Reports whether the element has zero bounding width and height.
-
#position ⇒ Sevgi::Geometry::Point
abstract
Returns the element position.
-
#translate(_x, _y) ⇒ Sevgi::Geometry::Element
abstract
Returns a translated copy.
Class Method Details
.lined(size = Undefined, open: false) ⇒ Class
23 |
# File 'lib/sevgi/geometry/element.rb', line 23 def self.lined(...) = Lined.send(:build, ...) |
Instance Method Details
#at(point = nil, dx: 0, dy: 0) ⇒ Sevgi::Geometry::Element
Returns a copy moved to a point and optional offset.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/sevgi/geometry/element.rb', line 48 def at(point = nil, dx: 0, dy: 0) point = point ? Tuple[Point, point] : position dx = Real[:dx, dx] dy = Real[:dy, dy] translate( (point.x - position.x) + dx, (point.y - position.y) + dy ) end |
#box ⇒ Sevgi::Geometry::Rect
Subclasses implement element-specific bounds.
Returns the bounding rectangle.
63 |
# File 'lib/sevgi/geometry/element.rb', line 63 def box = PanicError.("#{self.class}#box must be implemented") |
#equations ⇒ Array<Sevgi::Geometry::Equation>
Subclasses implement element-specific equations.
Returns equations that define the element boundary.
69 |
# File 'lib/sevgi/geometry/element.rb', line 69 def equations = PanicError.("#{self.class}#equations must be implemented") |
#ignorable?(precision: nil) ⇒ Boolean
Reports whether the element has zero bounding width and height.
74 |
# File 'lib/sevgi/geometry/element.rb', line 74 def ignorable?(precision: nil) = F.zero?(box.width, precision:) && F.zero?(box.height, precision:) |
#position ⇒ Sevgi::Geometry::Point
Subclasses implement element-specific positioning.
Returns the element position.
80 |
# File 'lib/sevgi/geometry/element.rb', line 80 def position = PanicError.("#{self.class}#position must be implemented") |
#translate(_x, _y) ⇒ Sevgi::Geometry::Element
Subclasses implement element-specific translation.
Returns a translated copy.
88 |
# File 'lib/sevgi/geometry/element.rb', line 88 def translate(_x, _y) = PanicError.("#{self.class}#translate must be implemented") |