Skip to content

Commit

Permalink
Refactor Renderer method visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Apr 9, 2024
1 parent 41ed7ce commit 5a8032e
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/gruff/renderer/renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand All @@ -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+.
Expand Down Expand Up @@ -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|
Expand Down

0 comments on commit 5a8032e

Please sign in to comment.