Class: StackedPdfGenerator::CropMarkDetector::LineCollector
- Inherits:
-
HexaPDF::Content::Processor
- Object
- HexaPDF::Content::Processor
- StackedPdfGenerator::CropMarkDetector::LineCollector
- Defined in:
- lib/stacked_pdf_generator/crop_mark_detector.rb
Overview
Walks the page content stream and records every line/rectangle edge in page coordinates (CTM applied).
Instance Attribute Summary collapse
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
Instance Method Summary collapse
- #append_rectangle(x, y, w, h) ⇒ Object
-
#initialize ⇒ LineCollector
constructor
A new instance of LineCollector.
- #line_to(x, y) ⇒ Object
- #move_to(x, y) ⇒ Object
Constructor Details
#initialize ⇒ LineCollector
Returns a new instance of LineCollector.
117 118 119 120 121 |
# File 'lib/stacked_pdf_generator/crop_mark_detector.rb', line 117 def initialize super @lines = [] @current = nil end |
Instance Attribute Details
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
115 116 117 |
# File 'lib/stacked_pdf_generator/crop_mark_detector.rb', line 115 def lines @lines end |
Instance Method Details
#append_rectangle(x, y, w, h) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/stacked_pdf_generator/crop_mark_detector.rb', line 136 def append_rectangle(x, y, w, h) edges = [ [x, y, x + w, y], [x + w, y, x + w, y + h], [x + w, y + h, x, y + h], [x, y + h, x, y] ] edges.each do |x0, y0, x1, y1| tx0, ty0 = transform_point(x0, y0) tx1, ty1 = transform_point(x1, y1) @lines << [tx0, ty0, tx1, ty1] end end |
#line_to(x, y) ⇒ Object
127 128 129 130 131 132 133 134 |
# File 'lib/stacked_pdf_generator/crop_mark_detector.rb', line 127 def line_to(x, y) if @current tx0, ty0 = transform_point(*@current) tx1, ty1 = transform_point(x, y) @lines << [tx0, ty0, tx1, ty1] end @current = [x, y] end |
#move_to(x, y) ⇒ Object
123 124 125 |
# File 'lib/stacked_pdf_generator/crop_mark_detector.rb', line 123 def move_to(x, y) @current = [x, y] end |