Class: Okab::ZaniahVector

Inherits:
Object
  • Object
show all
Defined in:
lib/okab/zaniah_vector.rb,
sig/okab.rbs

Overview

Optional bridge: each display-list item remains a PDF path, glyph, or image. Only effects without an equivalent PDF page operation are rasterized locally.

Constant Summary collapse

KAPPA =
0.5522847498307936

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page, vector_document) ⇒ ZaniahVector

Returns a new instance of ZaniahVector.



14
15
16
17
18
19
20
21
22
# File 'lib/okab/zaniah_vector.rb', line 14

def initialize(page, vector_document)
  unless page.is_a?(Page) && vector_document.is_a?(::Zaniah::Vector::Document)
    raise ArgumentError, "expected an Okab::Page and Zaniah::Vector::Document"
  end
  unless page.width == vector_document.width && page.height == vector_document.height
    raise ArgumentError, "PDF page and vector document dimensions must match"
  end
  @page, @vector, @fonts = page, vector_document, {}.compare_by_identity
end

Class Method Details

.draw(page, vector_document) ⇒ Page

Parameters:

  • page (Page)
  • vector_document (Object)

Returns:



12
# File 'lib/okab/zaniah_vector.rb', line 12

def self.draw(page, vector_document) = new(page, vector_document).draw

Instance Method Details

#draw ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/okab/zaniah_vector.rb', line 24

def draw
  @vector.commands.each do |command|
    clipped(command) do
      transformed(command) { draw_command(command) }
    end
  end
  @page
end