class CTioga2::Graphics::Elements::GradientRegion
A GradientRegion
is an object that makes color gradient for the curves. Especially useful for a great number of curves, and when one doesn't want to computeā¦
Like Region
It is a fake container in the sense that all the elements are actually forwarded to the parent.
Attributes
curves[RW]
The curves which delimit the region
end_color[RW]
The start and end colors
start_color[RW]
The start and end colors
Public Class Methods
new(parent, root, options)
click to toggle source
Creates a new empty region
# File lib/ctioga2/graphics/elements/gradient-region.rb, line 46 def initialize(parent, root, options) @parent = parent setup_style(parent, options) # The curves whose color we should change @curves = [] @root_object = root @legend_area = nil @start_color = Tioga::ColorConstants::Red @end_color = Tioga::ColorConstants::Green end
Public Instance Methods
add_element(element)
click to toggle source
Adds an element. Actually forwards it to the parent.
# File lib/ctioga2/graphics/elements/gradient-region.rb, line 63 def add_element(element) parent.add_element(element) if element.respond_to?(:curve_style) @curves << element end end
set_from_hash(hash)
click to toggle source
Sets the various things from hash.
# File lib/ctioga2/graphics/elements/gradient-region.rb, line 71 def set_from_hash(hash) end
Protected Instance Methods
real_do(t)
click to toggle source
Simply sets the color of the curves.
# File lib/ctioga2/graphics/elements/gradient-region.rb, line 77 def real_do(t) nb = @curves.size i = 0 for c in @curves c.curve_style.line.color = Utils::mix_objects(@end_color,@start_color, i/(nb - 1.0)) i += 1 end end