Class: Idml::Elements::PathGeometry
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Idml::Elements::PathGeometry
- Defined in:
- lib/idml/elements/path_geometry.rb
Overview
<PathGeometry> — the shape geometry of a page item. Contains
one or more GeometryPathType elements. Provides a
bounding_box convenience method that derives [y1, x1, y2, x2]
from the anchor points.
Instance Method Summary collapse
- #all_points ⇒ Object
-
#bounding_box ⇒ Object
Returns [y1, x1, y2, x2] from all anchor points across all paths.
Instance Method Details
#all_points ⇒ Object
29 30 31 32 33 |
# File 'lib/idml/elements/path_geometry.rb', line 29 def all_points return [] unless geometry_path_type geometry_path_type.flat_map(&:points) end |
#bounding_box ⇒ Object
Returns [y1, x1, y2, x2] from all anchor points across all paths. nil if no points.
20 21 22 23 24 25 26 27 |
# File 'lib/idml/elements/path_geometry.rb', line 20 def bounding_box pts = all_points return nil if pts.empty? xs = pts.map(&:x) ys = pts.map(&:y) [ys.min, xs.min, ys.max, xs.max] end |