Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add gradient background direction #9

Merged
merged 1 commit into from

3 participants

@fordguo

add gradient direct

@topfunky
Owner

Looks good, but could I get a test and better spacing?

For example, %w(black grey,:top_bottom) makes little sense. Just use a regular array if you are going to mix spaces and commas (and strings and symbols).

You could add to test_line.rb or similar to make a graph with the new gradient syntax.

@fordguo

en,the array is better
I will add the test for gradient,thanks good tips.

@donv donv was assigned
@donv donv merged commit 0b85fe4 into topfunky:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 28, 2010
  1. @fordguo

    add gradient direct

    fordguo authored
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 4 deletions.
  1. +13 −4 lib/gruff/base.rb
View
17 lib/gruff/base.rb
@@ -290,7 +290,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.
@@ -911,9 +911,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.
Something went wrong with that request. Please try again.