Class: Postsvg::Translation::Context
- Inherits:
-
Object
- Object
- Postsvg::Translation::Context
- Defined in:
- lib/postsvg/translation/context.rb
Overview
Mutable translation context carried through the SVG tree walk. Holds the emitter, the graphics state stack (so handlers can emit gsave/grestore around transforms), and the bounding box accumulator.
Instance Attribute Summary collapse
-
#bounding_box ⇒ Object
readonly
Returns the value of attribute bounding_box.
-
#clip_path_registry ⇒ Object
readonly
Returns the value of attribute clip_path_registry.
-
#emitter ⇒ Object
readonly
Returns the value of attribute emitter.
-
#graphics ⇒ Object
readonly
Returns the value of attribute graphics.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #eps? ⇒ Boolean
- #expand_bbox!(x_range, y_range) ⇒ Object
-
#initialize(emitter: RecordEmitter.new, graphics: GraphicsStack.new, bounding_box: BoundingBox.empty, clip_path_registry: ::Postsvg::Svg::ClipPathRegistry.empty, options: {}) ⇒ Context
constructor
A new instance of Context.
Constructor Details
#initialize(emitter: RecordEmitter.new, graphics: GraphicsStack.new, bounding_box: BoundingBox.empty, clip_path_registry: ::Postsvg::Svg::ClipPathRegistry.empty, options: {}) ⇒ Context
Returns a new instance of Context.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/postsvg/translation/context.rb', line 13 def initialize(emitter: RecordEmitter.new, graphics: GraphicsStack.new, bounding_box: BoundingBox.empty, clip_path_registry: ::Postsvg::Svg::ClipPathRegistry.empty, options: {}) @emitter = emitter @graphics = graphics @bounding_box = bounding_box @clip_path_registry = clip_path_registry @options = .freeze end |
Instance Attribute Details
#bounding_box ⇒ Object (readonly)
Returns the value of attribute bounding_box.
10 11 12 |
# File 'lib/postsvg/translation/context.rb', line 10 def bounding_box @bounding_box end |
#clip_path_registry ⇒ Object (readonly)
Returns the value of attribute clip_path_registry.
10 11 12 |
# File 'lib/postsvg/translation/context.rb', line 10 def clip_path_registry @clip_path_registry end |
#emitter ⇒ Object (readonly)
Returns the value of attribute emitter.
10 11 12 |
# File 'lib/postsvg/translation/context.rb', line 10 def emitter @emitter end |
#graphics ⇒ Object (readonly)
Returns the value of attribute graphics.
10 11 12 |
# File 'lib/postsvg/translation/context.rb', line 10 def graphics @graphics end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/postsvg/translation/context.rb', line 10 def @options end |
Instance Method Details
#eps? ⇒ Boolean
29 30 31 |
# File 'lib/postsvg/translation/context.rb', line 29 def eps? .fetch(:eps, false) end |
#expand_bbox!(x_range, y_range) ⇒ Object
25 26 27 |
# File 'lib/postsvg/translation/context.rb', line 25 def (x_range, y_range) @bounding_box = @bounding_box.(x_range, y_range) end |