Class: Emfsvg::Svg::Elements::ClipPath
- Inherits:
-
Emfsvg::Svg::Element
- Object
- Emfsvg::Svg::Element
- Emfsvg::Svg::Elements::ClipPath
- Defined in:
- lib/emfsvg/svg/elements/clip_path.rb
Overview
Defined Under Namespace
Classes: PathFlattenerForClip
Constant Summary collapse
- ELEMENT_NAME =
"clipPath"
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
-
#clip_bounds ⇒ Object
Bounds [left, top, right, bottom] of the clip region for IntersectClipRect emission.
-
#initialize(id:, children:) ⇒ ClipPath
constructor
A new instance of ClipPath.
-
#rectangular_bounds ⇒ Object
Alias retained for backward compatibility with shared_gdi.rb.
Methods inherited from Emfsvg::Svg::Element
#clip_path, #element_name, register
Constructor Details
#initialize(id:, children:) ⇒ ClipPath
Returns a new instance of ClipPath.
14 15 16 17 |
# File 'lib/emfsvg/svg/elements/clip_path.rb', line 14 def initialize(id:, children:) @id = id @children = children end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
12 13 14 |
# File 'lib/emfsvg/svg/elements/clip_path.rb', line 12 def children @children end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/emfsvg/svg/elements/clip_path.rb', line 12 def id @id end |
Class Method Details
Instance Method Details
#clip_bounds ⇒ Object
Bounds [left, top, right, bottom] of the clip region for IntersectClipRect emission. Handles three forms:
- Single
child — use rect bounds directly. - Single
child whose d-string traces a rectangle (4 unique corners + close) — extract corner bounds. - Anything else — use the union bounding box of all child geometry (lossy: curves flattened to bounds).
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/emfsvg/svg/elements/clip_path.rb', line 34 def clip_bounds return nil if children.empty? if children.size == 1 child = children.first return rect_bounds(child) if child.is_a?(Elements::Rect) return path_rect_bounds(child) if child.is_a?(Elements::Path) end bounding_box_of(children) end |
#rectangular_bounds ⇒ Object
Alias retained for backward compatibility with shared_gdi.rb.
47 48 49 |
# File 'lib/emfsvg/svg/elements/clip_path.rb', line 47 def rectangular_bounds clip_bounds end |