Class: Postsvg::Translation::Handlers::RectHandler

Inherits:
Object
  • Object
show all
Extended by:
Shared
Defined in:
lib/postsvg/translation/handlers/rect_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
# File 'lib/postsvg/translation/handlers/rect_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)
  x, y = element.x, element.y
  w, h = element.width, element.height
  context.emitter.emit(Model::Operators::Path::Moveto.new(x: x, y: y))
  context.emitter.emit(Model::Operators::Path::Rlineto.new(dx: w, dy: 0))
  context.emitter.emit(Model::Operators::Path::Rlineto.new(dx: 0, dy: h))
  context.emitter.emit(Model::Operators::Path::Rlineto.new(dx: -w, dy: 0))
  context.emitter.emit(Model::Operators::Path::Closepath.new)
  emit_paint(element, context)
  context.emitter.emit(Model::Operators::GraphicsState::Grestore.new)
  expand_bbox(context, x, y, x + w, y + h)
end