README.txt in interpolate-0.2.2 vs README.txt in interpolate-0.2.3

- old
+ new

@@ -51,25 +51,17 @@ == Non-Numeric Gradients For non-Numeric gradient value objects, you'll need to implement +interpolate+ -for the class in question. Here's an example using an RGB color gradient with -the help of the 'color' gem: +for the class in question or provide a block to the new Interpolation object. +Here's an example using an RGB color gradient with the help of the 'color' gem: require 'rubygems' require 'interpolate' require 'color' - # we need to implement +interpolate+ for Color::RGB - # in order for Interpolation to work - class Color::RGB - def interpolate(other, balance) - mix_with(other, balance * 100.0) - end - end - # a nice weathermap-style color gradient points = { 0 => Color::RGB::White, 1 => Color::RGB::Lime, # 2 => ? (something between Lime and Yellow) @@ -78,20 +70,23 @@ 5 => Color::RGB::Red, 6 => Color::RGB::Magenta, 7 => Color::RGB::DarkGray } - gradient = Interpolation.new(points) + 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 + == Array-based Interpolations Aside from single value gradient points, you can interpolate over uniformly sized arrays. Between two interpolation points, let's say +a+ and +b+, the final result will be +c+ where <tt>c[0]</tt> is the interpolation of <tt>a[0]</tt> and @@ -162,10 +157,10 @@ == License (The MIT License) -Copyright (c) 2008 Adam Collins [adam.w.collins@gmail.com] +Copyright (c) 2008-2009 Adam Collins [adam.w.collins@gmail.com] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish,