Class: Clef::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/clef/compiler.rb

Instance Method Summary collapse

Constructor Details

#initialize(score, style: Clef::Engraving::Style.default, plugins: Clef.plugins) ⇒ Compiler

Returns a new instance of Compiler.

Parameters:



8
9
10
11
12
# File 'lib/clef/compiler.rb', line 8

def initialize(score, style: Clef::Engraving::Style.default, plugins: Clef.plugins)
  @score = score
  @style = style
  @plugins = plugins
end

Instance Method Details

#compile_to_pdf(path) ⇒ String

Parameters:

  • path (String)

Returns:

  • (String)


16
17
18
19
20
21
22
23
24
# File 'lib/clef/compiler.rb', line 16

def compile_to_pdf(path)
  layout = build_layout
  renderer = Clef::Renderer::PdfRenderer.new(style: @style)
  @plugins.run_hook(:register_glyphs, renderer.glyph_table)
  @plugins.run_hook(:on_before_render, renderer)
  renderer.render(@score, path, positions: layout[:positions], layout: layout)
  @plugins.run_hook(:on_after_render, path)
  path
end

#compile_to_svg(path) ⇒ String

Parameters:

  • path (String)

Returns:

  • (String)


28
29
30
31
32
33
34
35
36
# File 'lib/clef/compiler.rb', line 28

def compile_to_svg(path)
  layout = build_layout
  renderer = Clef::Renderer::SvgRenderer.new(style: @style)
  @plugins.run_hook(:register_glyphs, renderer.glyph_table)
  @plugins.run_hook(:on_before_render, renderer)
  renderer.render(@score, path, positions: layout[:positions], layout: layout)
  @plugins.run_hook(:on_after_render, path)
  path
end