Class: Sevgi::Geometry::Element
- Inherits:
-
Object
- Object
- Sevgi::Geometry::Element
- Defined in:
- lib/sevgi/geometry/element.rb
Overview
Base class for geometric elements.
Defined Under Namespace
Class Method Summary collapse
-
.arced(*args) ⇒ Class
Builds an arced element subclass.
-
.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
.arced(*args) ⇒ Class
20 |
# File 'lib/sevgi/geometry/element.rb', line 20 def self.arced(...) = Arced.build(...) |
Instance Method Details
#at(point = nil, dx: 0, dy: 0) ⇒ Sevgi::Geometry::Element
Returns a copy moved to a point and optional offset.
30 31 32 33 34 35 36 37 |
# File 'lib/sevgi/geometry/element.rb', line 30 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.
43 |
# File 'lib/sevgi/geometry/element.rb', line 43 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.
49 |
# File 'lib/sevgi/geometry/element.rb', line 49 def equations = PanicError.("#{self.class}#equations must be implemented") |
#ignorable?(precision: nil) ⇒ Boolean
Reports whether the element has zero bounding width and height.
54 |
# File 'lib/sevgi/geometry/element.rb', line 54 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.
60 |
# File 'lib/sevgi/geometry/element.rb', line 60 def position = PanicError.("#{self.class}#position must be implemented") |
#translate(_x, _y) ⇒ Sevgi::Geometry::Element
Subclasses implement element-specific translation.
Returns a translated copy.
68 |
# File 'lib/sevgi/geometry/element.rb', line 68 def translate(_x, _y) = PanicError.("#{self.class}#translate must be implemented") |