Class: Squib::Graphics::SaveSpruePDF

Inherits:
SaveSprue
  • Object
show all
Defined in:
lib/squib/graphics/save_sprue.rb

Overview

Templated sheet renderer in PDF format.

Instance Method Summary collapse

Methods inherited from SaveSprue

#initialize, #render_sheet

Constructor Details

This class inherits a constructor from Squib::Graphics::SaveSprue

Instance Method Details

#draw_page(cc) ⇒ Object


172
173
174
175
176
177
# File 'lib/squib/graphics/save_sprue.rb', line 172

def draw_page(cc)
  cc.show_page
  cc.set_source_color(:white) # white backdrop TODO make option
  cc.paint
  cc
end

#full_filenameObject


179
180
181
# File 'lib/squib/graphics/save_sprue.rb', line 179

def full_filename
  @sheet_args.full_filename
end

#init_ccObject


158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/squib/graphics/save_sprue.rb', line 158

def init_cc
  ratio = 72.0 / @deck.dpi

  surface = Cairo::PDFSurface.new(
    full_filename,
    @tmpl.sheet_width * ratio,
    @tmpl.sheet_height * ratio
  )

  cc = Cairo::Context.new(surface)
  cc.scale(72.0 / @deck.dpi, 72.0 / @deck.dpi) # make it like pixels
  cc
end