Class: Shellfie::GifGenerator
- Inherits:
-
Object
- Object
- Shellfie::GifGenerator
- Defined in:
- lib/shellfie/gif_generator.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
Instance Method Summary collapse
- #generate(output_path, scale: 1, shadow: true, transparent: false, format: nil, io: nil) ⇒ Object
-
#initialize(config) ⇒ GifGenerator
constructor
A new instance of GifGenerator.
Constructor Details
#initialize(config) ⇒ GifGenerator
Returns a new instance of GifGenerator.
21 22 23 24 25 26 |
# File 'lib/shellfie/gif_generator.rb', line 21 def initialize(config) @config = config @renderer = Renderer.new(config) @theme = @renderer.theme @frame_builder = AnimationFrameBuilder.new(config) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
19 20 21 |
# File 'lib/shellfie/gif_generator.rb', line 19 def config @config end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
19 20 21 |
# File 'lib/shellfie/gif_generator.rb', line 19 def theme @theme end |
Instance Method Details
#generate(output_path, scale: 1, shadow: true, transparent: false, format: nil, io: nil) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/shellfie/gif_generator.rb', line 28 def generate(output_path, scale: 1, shadow: true, transparent: false, format: nil, io: nil) check_dependencies! images = [] chrome_cache = RenderChromeCache.new begin frames = playback_frames(coalesce_frames(build_animation_frames)) validate_frame_limit!(frames) validate_workload!(frames, scale: scale, shadow: shadow) warn_frame_count(frames) images = render_frames(frames, scale: scale, shadow: shadow, transparent: transparent, chrome_cache: chrome_cache) extension = FormatResolver.resolve(output_path, explicit: format, default: "gif") return write_png_sequence(images, output_path) if extension == "png-sequence" OutputWriter.write(output_path, extension: extension, io: io) do |temporary_path| combine_to_animation(images, temporary_path, format: extension) end ensure cleanup_temp_files(images) chrome_cache.cleanup end rescue MiniMagick::Error => e raise RenderError.new("ImageMagick animation render failed: #{e.}", category: :render) end |