Class: Pdfrb::Content::TilingPattern
- Inherits:
-
Object
- Object
- Pdfrb::Content::TilingPattern
- Defined in:
- lib/pdfrb/content/tiling_pattern.rb
Overview
Tiling patterns (ISO 32000-2 ยง8.7.3). A tiling pattern is a repeating cell that fills an area. Type 1 (constant spacing) and Type 2 (no distortion) are supported.
The pattern cell is drawn via a block using the Canvas API. Registered in page Resources under /Pattern.
Constant Summary collapse
- PATTERN_TYPE =
1
Instance Attribute Summary collapse
-
#bbox ⇒ Object
readonly
Returns the value of attribute bbox.
-
#paint_type ⇒ Object
readonly
Returns the value of attribute paint_type.
-
#tiling_type ⇒ Object
readonly
Returns the value of attribute tiling_type.
-
#x_step ⇒ Object
readonly
Returns the value of attribute x_step.
-
#y_step ⇒ Object
readonly
Returns the value of attribute y_step.
Instance Method Summary collapse
-
#initialize(paint_type: 1, tiling_type: 1, bbox: [0, 0, 16, 16], x_step: 16, y_step: 16) ⇒ TilingPattern
constructor
A new instance of TilingPattern.
-
#register_on(document, page) {|canvas| ... } ⇒ Symbol
Build the pattern stream and register it in the page's Resources.
Constructor Details
#initialize(paint_type: 1, tiling_type: 1, bbox: [0, 0, 16, 16], x_step: 16, y_step: 16) ⇒ TilingPattern
Returns a new instance of TilingPattern.
21 22 23 24 25 26 27 28 |
# File 'lib/pdfrb/content/tiling_pattern.rb', line 21 def initialize(paint_type: 1, tiling_type: 1, bbox: [0, 0, 16, 16], x_step: 16, y_step: 16) @paint_type = paint_type @tiling_type = tiling_type @bbox = bbox @x_step = x_step @y_step = y_step end |
Instance Attribute Details
#bbox ⇒ Object (readonly)
Returns the value of attribute bbox.
14 15 16 |
# File 'lib/pdfrb/content/tiling_pattern.rb', line 14 def bbox @bbox end |
#paint_type ⇒ Object (readonly)
Returns the value of attribute paint_type.
14 15 16 |
# File 'lib/pdfrb/content/tiling_pattern.rb', line 14 def paint_type @paint_type end |
#tiling_type ⇒ Object (readonly)
Returns the value of attribute tiling_type.
14 15 16 |
# File 'lib/pdfrb/content/tiling_pattern.rb', line 14 def tiling_type @tiling_type end |
#x_step ⇒ Object (readonly)
Returns the value of attribute x_step.
14 15 16 |
# File 'lib/pdfrb/content/tiling_pattern.rb', line 14 def x_step @x_step end |
#y_step ⇒ Object (readonly)
Returns the value of attribute y_step.
14 15 16 |
# File 'lib/pdfrb/content/tiling_pattern.rb', line 14 def y_step @y_step end |
Instance Method Details
#register_on(document, page) {|canvas| ... } ⇒ Symbol
Build the pattern stream and register it in the page's Resources.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/pdfrb/content/tiling_pattern.rb', line 35 def register_on(document, page) pattern_stream = document.add( { Type: :Pattern, PatternType: PATTERN_TYPE, PaintType: @paint_type, TilingType: @tiling_type, BBox: @bbox, XStep: @x_step, YStep: @y_step, }, type: Pdfrb::Model::Cos::Stream ) if block_given? canvas = Pdfrb::Content::Canvas.new(pattern_stream, document: document) yield canvas end ref = Pdfrb::Model::Reference.new(pattern_stream.oid, pattern_stream.gen) register_in_resources(document, page, ref) end |