From 5a8032efa6fbf44b471bcf6dca2e5914dd837c17 Mon Sep 17 00:00:00 2001 From: Watson Date: Wed, 10 Apr 2024 00:47:54 +0900 Subject: [PATCH] Refactor Renderer method visibility --- lib/gruff/renderer/renderer.rb | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/gruff/renderer/renderer.rb b/lib/gruff/renderer/renderer.rb index bc39173b..593c6407 100644 --- a/lib/gruff/renderer/renderer.rb +++ b/lib/gruff/renderer/renderer.rb @@ -23,6 +23,12 @@ def finish end end + def transparent_background(columns, rows) + @image = render_transparent_background(columns, rows) + end + + private + def background(columns, rows, scale, theme_options) return image_background(scale, *theme_options[:background_image]) if theme_options[:background_image] @@ -36,8 +42,13 @@ def background(columns, rows, scale, theme_options) end end - def transparent_background(columns, rows) - @image = render_transparent_background(columns, rows) + # Use with a theme to use an image (800x600 original) background. + def image_background(scale, image_path) + image = Magick::Image.read(image_path) + if scale != 1.0 + image[0].resize!(scale) # TODO: Resize with new scale (crop if necessary for wide graph) + end + image[0] end # Make a new image at the current size with a solid +color+. @@ -82,17 +93,6 @@ def gradated_background(columns, rows, top_color, bottom_color, direct = :top_bo end end - private - - # Use with a theme to use an image (800x600 original) background. - def image_background(scale, image_path) - image = Magick::Image.read(image_path) - if scale != 1.0 - image[0].resize!(scale) # TODO: Resize with new scale (crop if necessary for wide graph) - end - image[0] - end - # Use with a theme to make a transparent background def render_transparent_background(columns, rows) Magick::Image.new(columns, rows) do |img|