Class: Rainbow::ColorRange
- Inherits:
-
Object
- Object
- Rainbow::ColorRange
- Defined in:
- lib/rainbow/color_range.rb
Instance Attribute Summary collapse
-
#current_x ⇒ Object
Returns the value of attribute current_x.
-
#first_width ⇒ Object
readonly
Returns the value of attribute first_width.
-
#from_color ⇒ Object
readonly
Returns the value of attribute from_color.
-
#from_location_in_pixel ⇒ Object
readonly
Returns the value of attribute from_location_in_pixel.
-
#gradient ⇒ Object
Returns the value of attribute gradient.
-
#leftover_width ⇒ Object
readonly
Returns the value of attribute leftover_width.
-
#mid_color ⇒ Object
readonly
Returns the value of attribute mid_color.
-
#mid_location_in_pixel ⇒ Object
readonly
Returns the value of attribute mid_location_in_pixel.
-
#mid_point ⇒ Object
readonly
Returns the value of attribute mid_point.
-
#opacity_ranges ⇒ Object
Returns the value of attribute opacity_ranges.
-
#second_width ⇒ Object
readonly
Returns the value of attribute second_width.
-
#tmp_current_x ⇒ Object
readonly
Returns the value of attribute tmp_current_x.
-
#tmp_diff_b ⇒ Object
readonly
Returns the value of attribute tmp_diff_b.
-
#tmp_diff_g ⇒ Object
readonly
Returns the value of attribute tmp_diff_g.
-
#tmp_diff_r ⇒ Object
readonly
Returns the value of attribute tmp_diff_r.
-
#tmp_distance_in_pixel ⇒ Object
readonly
Returns the value of attribute tmp_distance_in_pixel.
-
#tmp_from_color ⇒ Object
readonly
Returns the value of attribute tmp_from_color.
-
#tmp_to_color ⇒ Object
readonly
Returns the value of attribute tmp_to_color.
-
#to_color ⇒ Object
readonly
Returns the value of attribute to_color.
-
#to_location_in_pixel ⇒ Object
readonly
Returns the value of attribute to_location_in_pixel.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #current_color ⇒ Object
-
#initialize(from_color, to_color, mid_point) ⇒ ColorRange
constructor
A new instance of ColorRange.
Constructor Details
#initialize(from_color, to_color, mid_point) ⇒ ColorRange
Returns a new instance of ColorRange.
12 13 14 15 16 17 18 |
# File 'lib/rainbow/color_range.rb', line 12 def initialize(from_color, to_color, mid_point) @from_color = from_color @to_color = to_color @mid_point = mid_point @current_x = nil end |
Instance Attribute Details
#current_x ⇒ Object
Returns the value of attribute current_x.
4 5 6 |
# File 'lib/rainbow/color_range.rb', line 4 def current_x @current_x end |
#first_width ⇒ Object (readonly)
Returns the value of attribute first_width.
4 5 6 |
# File 'lib/rainbow/color_range.rb', line 4 def first_width @first_width end |
#from_color ⇒ Object (readonly)
Returns the value of attribute from_color.
3 4 5 |
# File 'lib/rainbow/color_range.rb', line 3 def from_color @from_color end |
#from_location_in_pixel ⇒ Object (readonly)
Returns the value of attribute from_location_in_pixel.
5 6 7 |
# File 'lib/rainbow/color_range.rb', line 5 def from_location_in_pixel @from_location_in_pixel end |
#gradient ⇒ Object
Returns the value of attribute gradient.
3 4 5 |
# File 'lib/rainbow/color_range.rb', line 3 def gradient @gradient end |
#leftover_width ⇒ Object (readonly)
Returns the value of attribute leftover_width.
5 6 7 |
# File 'lib/rainbow/color_range.rb', line 5 def leftover_width @leftover_width end |
#mid_color ⇒ Object (readonly)
Returns the value of attribute mid_color.
3 4 5 |
# File 'lib/rainbow/color_range.rb', line 3 def mid_color @mid_color end |
#mid_location_in_pixel ⇒ Object (readonly)
Returns the value of attribute mid_location_in_pixel.
5 6 7 |
# File 'lib/rainbow/color_range.rb', line 5 def mid_location_in_pixel @mid_location_in_pixel end |
#mid_point ⇒ Object (readonly)
Returns the value of attribute mid_point.
3 4 5 |
# File 'lib/rainbow/color_range.rb', line 3 def mid_point @mid_point end |
#opacity_ranges ⇒ Object
Returns the value of attribute opacity_ranges.
10 11 12 |
# File 'lib/rainbow/color_range.rb', line 10 def opacity_ranges @opacity_ranges end |
#second_width ⇒ Object (readonly)
Returns the value of attribute second_width.
4 5 6 |
# File 'lib/rainbow/color_range.rb', line 4 def second_width @second_width end |
#tmp_current_x ⇒ Object (readonly)
Returns the value of attribute tmp_current_x.
7 8 9 |
# File 'lib/rainbow/color_range.rb', line 7 def tmp_current_x @tmp_current_x end |
#tmp_diff_b ⇒ Object (readonly)
Returns the value of attribute tmp_diff_b.
7 8 9 |
# File 'lib/rainbow/color_range.rb', line 7 def tmp_diff_b @tmp_diff_b end |
#tmp_diff_g ⇒ Object (readonly)
Returns the value of attribute tmp_diff_g.
7 8 9 |
# File 'lib/rainbow/color_range.rb', line 7 def tmp_diff_g @tmp_diff_g end |
#tmp_diff_r ⇒ Object (readonly)
Returns the value of attribute tmp_diff_r.
7 8 9 |
# File 'lib/rainbow/color_range.rb', line 7 def tmp_diff_r @tmp_diff_r end |
#tmp_distance_in_pixel ⇒ Object (readonly)
Returns the value of attribute tmp_distance_in_pixel.
7 8 9 |
# File 'lib/rainbow/color_range.rb', line 7 def tmp_distance_in_pixel @tmp_distance_in_pixel end |
#tmp_from_color ⇒ Object (readonly)
Returns the value of attribute tmp_from_color.
7 8 9 |
# File 'lib/rainbow/color_range.rb', line 7 def tmp_from_color @tmp_from_color end |
#tmp_to_color ⇒ Object (readonly)
Returns the value of attribute tmp_to_color.
7 8 9 |
# File 'lib/rainbow/color_range.rb', line 7 def tmp_to_color @tmp_to_color end |
#to_color ⇒ Object (readonly)
Returns the value of attribute to_color.
3 4 5 |
# File 'lib/rainbow/color_range.rb', line 3 def to_color @to_color end |
#to_location_in_pixel ⇒ Object (readonly)
Returns the value of attribute to_location_in_pixel.
5 6 7 |
# File 'lib/rainbow/color_range.rb', line 5 def to_location_in_pixel @to_location_in_pixel end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
4 5 6 |
# File 'lib/rainbow/color_range.rb', line 4 def width @width end |
Instance Method Details
#current_color ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/rainbow/color_range.rb', line 33 def current_color if less_than_scale_range? ChunkyPNG::Color(from_color.r, from_color.g, from_color.b, @tmp_opacity) elsif greater_than_scale_range? ChunkyPNG::Color(to_color.r, to_color.g, to_color.b, @tmp_opacity) else ChunkyPNG::Color(color(:r), color(:g), color(:b), @tmp_opacity) end end |