Class: Emfsvg::Translation::Handlers::PathHandler

Inherits:
Object
  • Object
show all
Includes:
Emf::Emr::Binary::TypeCodes, SharedGdi
Defined in:
lib/emfsvg/translation/handlers/path_handler.rb

Overview

Translate to EMF drawing records.

v1 strategy: flatten to absolute, fully-resolved points. Bezier control points are preserved as cubic Beziers; arcs/quads are approximated (TODO). Emits a single PolyBezier record when cubics are present, else Polyline / Polygon.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SharedGdi

#clip_bounds_for, #emit_create_brush, #emit_create_pen, #emit_delete, #emit_restore_dc, #emit_save_dc, #with_gdi_state

Class Method Details

.call(element, context) ⇒ Object



18
19
20
# File 'lib/emfsvg/translation/handlers/path_handler.rb', line 18

def self.call(element, context)
  new.translate(element, context)
end

Instance Method Details

#translate(element, context) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/emfsvg/translation/handlers/path_handler.rb', line 22

def translate(element, context)
  return if element.commands.empty?

  with_gdi_state(element, context) do
    flattened = PathFlattener.flatten(element.commands)
    emit_path(flattened, element, context)
  end
end