Sha256: b5efee3bcc23b1963aaff43f8f88e3c49cbccd0cc8a9fc84f96ad78ef5b9938c
Contents?: true
Size: 834 Bytes
Versions: 1
Compression:
Stored size: 834 Bytes
Contents
require 'rubygems' require 'interpolate' require 'color' # a nice weathermap-style color gradient points = { 0 => Color::RGB::White, 1 => Color::RGB::Lime, # 2 => ? (something between Lime and Yellow) 3 => Color::RGB::Yellow, 4 => Color::RGB::Orange, 5 => Color::RGB::Red, 6 => Color::RGB::Magenta, 7 => Color::RGB::DarkGray } # Color objects can't interpolate themselves right out of the box, # so rather than monkey patch the :interpolate method, you can pass # a block with the instantiation of a new Interpolation object gradient = Interpolation.new(points) do |left, right, balance| left.mix_with(right, balance * 100.0) end # what are the colors of the gradient from 0 to 7 # in increments of 0.2? (0).step(7, 0.2) do |value| color = gradient.at(value) puts "A value of #{value} means #{color.html}" end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
interpolate-0.2.3 | examples/colors.rb |