Skip to content
Browse files

Merge pull request #9 from fordguo/gradient

Add gradient background direction
  • Loading branch information...
2 parents fe8b7c7 + 7510c59 commit 0b85fe4a36b084c9f4f837ee028009a741b841db @donv donv committed Nov 9, 2012
Showing with 13 additions and 4 deletions.
  1. +13 −4 lib/gruff/base.rb
View
17 lib/gruff/base.rb
@@ -304,7 +304,7 @@ def replace_colors(color_list=[])
# graph.theme = {
# :colors => %w(orange purple green white red),
# :marker_color => 'blue',
- # :background_colors => %w(black grey)
+ # :background_colors => %w(black grey,:top_bottom)
# }
#
# :background_image => 'squirrel.png' is also possible.
@@ -851,9 +851,18 @@ def render_solid_background(color)
end
# Use with a theme definition method to draw a gradiated background.
- def render_gradiated_background(top_color, bottom_color)
- Image.new(@columns, @rows,
- GradientFill.new(0, 0, 100, 0, top_color, bottom_color))
+ def render_gradiated_background(top_color, bottom_color,direct=:top_bottom)
+ case direct
+ when :bottom_top
+ gradient_fill = GradientFill.new(100, 0, 0, 0, top_color, bottom_color)
+ when :left_right
+ gradient_fill = GradientFill.new(0, 0, 0, 100, top_color, bottom_color)
+ when :right_left
+ gradient_fill = GradientFill.new(0,100,0,0,top_color,bottom_color)
+ else
+ gradient_fill = GradientFill.new(0, 0, 100, 0, top_color, bottom_color)
+ end
+ Image.new(@columns, @rows,gradient_fill)
end
# Use with a theme to use an image (800x600 original) background.

0 comments on commit 0b85fe4

Please sign in to comment.
Something went wrong with that request. Please try again.