Class: Prawn::SVG::Elements::Pattern
- Defined in:
- lib/prawn/svg/elements/pattern.rb
Constant Summary
Constants inherited from Base
Base::COMMA_WSP_REGEXP, Base::MissingAttributesError, Base::PAINT_TYPES, Base::SVG_NAMESPACE, Base::SkipElementError, Base::SkipElementQuietly
Constants included from Attributes::Stroke
Attributes::Stroke::CAP_STYLE_TRANSLATIONS, Attributes::Stroke::JOIN_STYLE_TRANSLATIONS
Instance Attribute Summary collapse
-
#parent_pattern ⇒ Object
readonly
Returns the value of attribute parent_pattern.
Attributes inherited from Base
#attributes, #base_calls, #calls, #document, #parent_calls, #properties, #source, #state
Instance Method Summary collapse
- #container? ⇒ Boolean
- #derive_attribute(name) ⇒ Object
- #parse ⇒ Object
- #pattern_arguments(element) ⇒ Object
Methods inherited from Base
#initialize, #name, #parse_and_apply, #process
Methods included from TransformParser
Methods included from PDFMatrix
#load_matrix, #matrix_for_pdf, #rotation_matrix, #scale_matrix, #translation_matrix
Methods included from Attributes::Space
Methods included from Attributes::Stroke
#parse_stroke_attributes_and_call
Methods included from Attributes::Mask
#parse_mask_attribute_and_call
Methods included from Attributes::ClipPath
#parse_clip_path_attribute_and_call
Methods included from Attributes::Opacity
#parse_opacity_attributes_and_call
Methods included from Attributes::Transform
#parse_transform_attribute_and_call
Constructor Details
This class inherits a constructor from Prawn::SVG::Elements::Base
Instance Attribute Details
#parent_pattern ⇒ Object (readonly)
Returns the value of attribute parent_pattern.
2 3 4 |
# File 'lib/prawn/svg/elements/pattern.rb', line 2 def parent_pattern @parent_pattern end |
Instance Method Details
#container? ⇒ Boolean
14 15 16 |
# File 'lib/prawn/svg/elements/pattern.rb', line 14 def container? true end |
#derive_attribute(name) ⇒ Object
48 49 50 |
# File 'lib/prawn/svg/elements/pattern.rb', line 48 def derive_attribute(name) attributes[name] || parent_pattern&.derive_attribute(name) end |
#parse ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/prawn/svg/elements/pattern.rb', line 4 def parse raise SkipElementQuietly if attributes['id'].nil? @parent_pattern = document.gradients[href_attribute[1..]] if href_attribute && href_attribute[0] == '#' set_display_none document.gradients[attributes['id']] = self end |
#pattern_arguments(element) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/prawn/svg/elements/pattern.rb', line 18 def pattern_arguments(element) bbox = element.bounding_box units = derive_attribute('patternUnits') || 'objectBoundingBox' content_units = derive_attribute('patternContentUnits') || 'userSpaceOnUse' view_box_attr = derive_attribute('viewBox') par_attr = derive_attribute('preserveAspectRatio') tile = compute_tile(units, bbox) return nil unless tile tile_x, tile_y_bottom, tile_w, tile_h = tile transform = Matrix.identity(3) if (transform_attr = derive_attribute('patternTransform')) transform = parse_transform_attribute(transform_attr, space: :svg) end content_calls = build_content_calls(content_units, view_box_attr, par_attr, tile_w, tile_h, bbox, units, tile_x, tile_y_bottom) return nil if content_calls.nil? { tile_x: tile_x, tile_y: tile_y_bottom, tile_width: tile_w, tile_height: tile_h, transform: transform, calls: content_calls } end |