Class: Postsvg::Translation::Handlers::CircleHandler

Inherits:
Object
  • Object
show all
Extended by:
Shared
Defined in:
lib/postsvg/translation/handlers/circle_handler.rb

Class Method Summary collapse

Methods included from Shared

emit_fill, emit_paint, emit_paint_setup, emit_stroke, emit_transform, expand_bbox

Class Method Details

.call(element, context) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/postsvg/translation/handlers/circle_handler.rb', line 9

def self.call(element, context)
  context.emitter.emit(Model::Operators::GraphicsState::Gsave.new)
  emit_transform(element, context)
  context.emitter.emit(Model::Operators::Path::Newpath.new)
  r = element.r
  cx = element.cx
  cy = element.cy
  if r.to_f.positive?
    context.emitter.emit(Model::Operators::Path::Arc.new(
      x: cx, y: cy, radius: r, angle1: 0, angle2: 360,
    ))
  end
  emit_paint(element, context)
  context.emitter.emit(Model::Operators::GraphicsState::Grestore.new)
  expand_bbox(context, cx - r, cy - r, cx + r, cy + r)
end