Module: Idml::Render::Contour
- Defined in:
- lib/idml/render/contour.rb
Overview
Renders a page item's PathGeometry as true Bézier contours on a pdfrb canvas. Shared by OvalRenderer, PathRenderer, and PolygonRenderer: every item whose Properties carry a PathGeometry draws its actual outline — PathPointType anchors with LeftDirection / RightDirection control handles, ItemTransform applied, y flipped into PDF space — instead of its bounding box. Paint op selection (fill / stroke / gradient) lives in ShapePaint. Items without usable geometry fall back to the bounding-box rectangle.
Class Method Summary collapse
-
.draw_path(canvas, paths, item_transform, page_height) ⇒ Object
Constructs the full path on the canvas: one subpath per GeometryPathType, each starting at its first anchor and curving through every subsequent anchor via the points' control handles.
-
.geometry_paths(item) ⇒ Object
All GeometryPathType children across the item's Properties.
-
.render(canvas, context) ⇒ Object
Renders the item's contours with fill/stroke from ShapePaint.
Class Method Details
.draw_path(canvas, paths, item_transform, page_height) ⇒ Object
Constructs the full path on the canvas: one subpath per GeometryPathType, each starting at its first anchor and curving through every subsequent anchor via the points' control handles. Closed paths (PathOpen false or absent) loop back to the first anchor and close.
51 52 53 54 55 56 |
# File 'lib/idml/render/contour.rb', line 51 def self.draw_path(canvas, paths, item_transform, page_height) transform = Geometry.parse_transform(item_transform) paths.each do |path| draw_subpath(canvas, path, transform, page_height) end end |
.geometry_paths(item) ⇒ Object
All GeometryPathType children across the item's Properties.
40 41 42 43 44 |
# File 'lib/idml/render/contour.rb', line 40 def self.geometry_paths(item) item.properties.flat_map do |props| props.path_geometry.flat_map(&:geometry_path_type) end end |
.render(canvas, context) ⇒ Object
Renders the item's contours with fill/stroke from ShapePaint. Returns true when painted.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/idml/render/contour.rb', line 17 def self.render(canvas, context) item = context.item return false if item.visible == false paths = geometry_paths(item) return rectangle_fallback(canvas, item, context) if paths.empty? ShapePaint.paint(canvas, item, context) do |c| draw_path(c, paths, item.item_transform, context.page_height) end end |