Module: Postsvg::Visitors::PsVisitor::Painting

Included in:
Postsvg::Visitors::PsVisitor
Defined in:
lib/postsvg/visitors/ps_visitor/painting.rb

Overview

Painting operator handlers. Each flushes the current path through the SvgBuilder with the appropriate mode and color, then resets the path.

Instance Method Summary collapse

Instance Method Details

#visit_clip(_op, _ctx) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/postsvg/visitors/ps_visitor/painting.rb', line 25

def visit_clip(_op, _ctx)
  return if @path.empty?

  path_d = @path.to_path_d
  clip_id = @builder.register_clip_path(path_d)
  @graphics.update(clip_paths: @graphics.current.clip_paths + [clip_id])
  @path.reset
end

#visit_eoclip(_op, _ctx) ⇒ Object



34
35
36
# File 'lib/postsvg/visitors/ps_visitor/painting.rb', line 34

def visit_eoclip(_op, _ctx)
  visit_clip(nil, nil)
end

#visit_eofill(_op, _ctx) ⇒ Object



20
21
22
23
# File 'lib/postsvg/visitors/ps_visitor/painting.rb', line 20

def visit_eofill(_op, _ctx)
  flush_path(:fill)
  @path.reset
end

#visit_fill(_op, _ctx) ⇒ Object



15
16
17
18
# File 'lib/postsvg/visitors/ps_visitor/painting.rb', line 15

def visit_fill(_op, _ctx)
  flush_path(:fill)
  @path.reset
end

#visit_stroke(_op, _ctx) ⇒ Object



10
11
12
13
# File 'lib/postsvg/visitors/ps_visitor/painting.rb', line 10

def visit_stroke(_op, _ctx)
  flush_path(:stroke)
  @path.reset
end