Class: Prawn::SVG::Elements::Root

Inherits:
Base
  • Object
show all
Defined in:
lib/prawn/svg/elements/root.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

Attributes inherited from Base

#attributes, #base_calls, #calls, #document, #parent_calls, #properties, #source, #state

Instance Method Summary collapse

Methods inherited from Base

#name, #parse_and_apply, #process

Methods included from TransformParser

#parse_transform_attribute

Methods included from PDFMatrix

#load_matrix, #matrix_for_pdf, #rotation_matrix, #scale_matrix, #translation_matrix

Methods included from Attributes::Space

#parse_xml_space_attribute

Methods included from Attributes::Stroke

#parse_stroke_attributes_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

#initialize(document, source = document.root, parent_calls = [], state = ::Prawn::SVG::State.new) ⇒ Root

Returns a new instance of Root.



2
3
4
# File 'lib/prawn/svg/elements/root.rb', line 2

def initialize(document, source = document.root, parent_calls = [], state = ::Prawn::SVG::State.new)
  super
end

Instance Method Details

#applyObject



10
11
12
13
14
15
16
17
# File 'lib/prawn/svg/elements/root.rb', line 10

def apply
  if [nil, 'inherit'].include?(properties.fill) || properties.fill.none? || properties.fill.color == :currentcolor
    add_call 'fill_color', Prawn::SVG::Color.default_color(@document.color_mode).value
  end

  add_call 'transformation_matrix', @document.sizing.x_scale, 0, 0, @document.sizing.y_scale, 0, 0
  add_call 'transformation_matrix', 1, 0, 0, 1, -@document.sizing.x_offset, @document.sizing.y_offset
end

#container?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/prawn/svg/elements/root.rb', line 19

def container?
  true
end

#parseObject



6
7
8
# File 'lib/prawn/svg/elements/root.rb', line 6

def parse
  state.viewport_sizing = @document.sizing
end