Class: Sevgi::Geometry::Element
- Inherits:
-
Object
- Object
- Sevgi::Geometry::Element
- Defined in:
- lib/sevgi/geometry/element.rb
Overview
Base class for geometric elements.
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
Instance Method Details
#at(point = nil, dx: 0, dy: 0) ⇒ Sevgi::Geometry::Element
Returns a copy moved to a point and optional offset.
32 33 34 35 36 37 38 39 |
# File 'lib/sevgi/geometry/element.rb', line 32 def at(point = nil, dx: 0, dy: 0) point = point ? Tuple[Point, point] : position 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.
45 |
# File 'lib/sevgi/geometry/element.rb', line 45 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.
51 |
# File 'lib/sevgi/geometry/element.rb', line 51 def equations = PanicError.("#{self.class}#equations must be implemented") |
#ignorable?(precision: nil) ⇒ Boolean
Reports whether the element has zero bounding width and height.
56 |
# File 'lib/sevgi/geometry/element.rb', line 56 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.
62 |
# File 'lib/sevgi/geometry/element.rb', line 62 def position = PanicError.("#{self.class}#position must be implemented") |
#translate(_x, _y) ⇒ Sevgi::Geometry::Element
Subclasses implement element-specific translation.
Returns a translated copy.
70 |
# File 'lib/sevgi/geometry/element.rb', line 70 def translate(_x, _y) = PanicError.("#{self.class}#translate must be implemented") |