Class: Postsvg::Converter
- Inherits:
-
Object
- Object
- Postsvg::Converter
- Defined in:
- lib/postsvg/converter.rb
Overview
Converts PostScript/EPS to SVG by interpreting PostScript commands
Instance Attribute Summary collapse
-
#graphics_state ⇒ Object
readonly
Returns the value of attribute graphics_state.
-
#ps_content ⇒ Object
readonly
Returns the value of attribute ps_content.
-
#svg_generator ⇒ Object
readonly
Returns the value of attribute svg_generator.
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(ps_content) ⇒ Converter
constructor
A new instance of Converter.
Constructor Details
#initialize(ps_content) ⇒ Converter
Returns a new instance of Converter.
11 12 13 14 15 16 17 |
# File 'lib/postsvg/converter.rb', line 11 def initialize(ps_content) @ps_content = ps_content @graphics_state = GraphicsState.new @svg_generator = SvgGenerator.new @stack = [] @dictionary = {} end |
Instance Attribute Details
#graphics_state ⇒ Object (readonly)
Returns the value of attribute graphics_state.
9 10 11 |
# File 'lib/postsvg/converter.rb', line 9 def graphics_state @graphics_state end |
#ps_content ⇒ Object (readonly)
Returns the value of attribute ps_content.
9 10 11 |
# File 'lib/postsvg/converter.rb', line 9 def ps_content @ps_content end |
#svg_generator ⇒ Object (readonly)
Returns the value of attribute svg_generator.
9 10 11 |
# File 'lib/postsvg/converter.rb', line 9 def svg_generator @svg_generator end |
Instance Method Details
#convert ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/postsvg/converter.rb', line 19 def convert # Parse PostScript ast = Parser.parse(ps_content) # Extract BoundingBox for SVG viewBox extract_bounding_box # Execute PostScript commands execute_program(ast[:statements]) # Generate SVG svg_generator.generate( width: @bbox_width, height: @bbox_height, viewbox: @viewbox, ) end |