Module: Rubyvis::Scale
Defined Under Namespace
Classes: Linear, Log, Ordinal, Quantitative
Class Method Summary
collapse
Class Method Details
.interpolator(start, _end) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/rubyvis/scale.rb', line 18
def self.interpolator(start,_end)
if start.is_a? Numeric
return lambda {|t| t*(_end-start)+start}
end
start=Rubyvis.color(start).rgb()
_end = Rubyvis.color(_end).rgb()
return lambda {|t|
a=start.a*(1-t)+_end.a*t
a=0 if a<1e-5
return (start.a == 0) ? Rubyvis.rgb(_end.r, _end.g, _end.b, a) : ((_end.a == 0) ? Rubyvis.rgb(start.r, start.g, start.b, a) : Rubyvis.rgb(
(start.r * (1 - t) + _end.r * t).round,
(start.g * (1 - t) + _end.g * t).round,
(start.b * (1 - t) + _end.b * t).round, a))
}
end
|
.linear(*args) ⇒ Object
9
10
11
|
# File 'lib/rubyvis/scale.rb', line 9
def self.linear(*args)
Linear.new(*args)
end
|
.log(*args) ⇒ Object
15
16
17
|
# File 'lib/rubyvis/scale.rb', line 15
def self.log(*args)
Log.new(*args)
end
|
.ordinal(*args) ⇒ Object
12
13
14
|
# File 'lib/rubyvis/scale.rb', line 12
def self.ordinal(*args)
Ordinal.new(*args)
end
|
.quantitative(*args) ⇒ Object
6
7
8
|
# File 'lib/rubyvis/scale.rb', line 6
def self.quantitative(*args)
Quantitative.new(*args)
end
|