Class: Postsvg::Translation::Handlers::EllipseHandler
- Inherits:
-
Object
- Object
- Postsvg::Translation::Handlers::EllipseHandler
- Extended by:
- Shared
- Defined in:
- lib/postsvg/translation/handlers/ellipse_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 25 26 27 |
# File 'lib/postsvg/translation/handlers/ellipse_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) cx = element.cx cy = element.cy rx = element.rx ry = element.ry # Approximate ellipse with scale + arc. if rx.to_f.positive? && ry.to_f.positive? scale = rx / ry context.emitter.emit(Model::Operators::Transformations::Translate.new(tx: cx, ty: cy)) context.emitter.emit(Model::Operators::Transformations::Scale.new(sx: scale, sy: 1)) context.emitter.emit(Model::Operators::Path::Arc.new(x: 0, y: 0, radius: ry, angle1: 0, angle2: 360)) end emit_paint(element, context) context.emitter.emit(Model::Operators::GraphicsState::Grestore.new) (context, cx - rx, cy - ry, cx + rx, cy + ry) end |