Hi Vitor,
I got lerpColor() working in Processing.js. It turned out to be pretty
simple once I'd figured out how to do lerp(), I just call the function
on each channel like so:
p.lerpColor = function lerpColor( c1, c2, amt ){
// Get RGBA values for Color 1 to floats
var colors1 = p.color(c1).split(",");
var r1 = parseFloat( colors1[0].split("(")[1] );
var g1 = parseFloat( colors1[1] );
var b1 = parseFloat( colors1[2] );
var a1 = parseFloat( colors1[3].split(")")[0] );
// Get RGBA values for Color 2 to floats
var colors2 = p.color(c2).split(",");
var r2 = parseFloat( colors2[0].split("(")[1] );
var g2 = parseFloat( colors2[1] );
var b2 = parseFloat( colors2[2] );
var a2 = parseFloat( colors2[3].split(")")[0] );
// Return lerp value for each channel, INT for color, Float for
Alpha-range
var r = parseInt( p.lerp(r1, r2, amt) );
var g = parseInt( p.lerp(g1, g2, amt) );
var b = parseInt( p.lerp(b1, b2, amt) );
var a = parseFloat( p.lerp(a1, a2, amt) );
aColor = "rgba(" + r + "," + g + "," + b + "," + a + ")";
return aColor;
}
I added it after the p.color( function in Processing.js. you can copy
and paste from my source here:
http://github.com/F1LT3R/processing-js/tree/master/processing.js
I gotta say, the more I dig into the Processing.js code, the more
impressive John's code looks, it's broken down in such a simple
modular way that anyone can come along and expand it. I really hope
the 3D functions get added within a year or two. I think we are
waiting on W3C before the browser can use the computers OpenGL
hardware on Canvas (for everyone) ???.... I think.
> cool. thanks.
> did you created it from scratch or did you "translated" from the processing
> java source?
> i also need lerpColor, but i imagine i could do it to if only i had the
> processing java source...
>
> 2008/11/13 F1LT3R <
alistairmacdon...@me.com>