XML Feeds

.

[javascript-dev] event-driven list interpolation- javascript solution?

volker böhm vboehm at gmx.ch
Fri Apr 25 02:34:39 MDT 2008


On 24 Apr 2008, at 16:49, joshua goldberg wrote:
>
> the below is pre-posted on the big list.  the only answer came from  
> brad garton, and while i'm grateful for his attention, i'd rather  
> implement this in a language that i can actually understand.
>
> is there an elegant javascript solution for this?  i'd be grateful  
> for a push in the right direction.  my procedural programming  
> skills have drastically withered on the vine.

this is a quick hack, so i doubt the example below is elegant.
could probably be streamlined, but maybe it gets you in the right  
direction.
volker.

careful, email coding!

/* --- start listInterpol.js ---- */
var a = 0;
var b = 0;
var a0 = 0;
var b0 = 0;

function list() {
	var incrA, incrB, x, y, dist = 0;
	a0 = a;	b0 = b;	
	a = arguments[0];	
	b = arguments[1];		
	// calc difference	
	x = a - a0;	
	y = b - b0;	
	// max. distance	
	dist = Math.max(Math.abs(x),Math.abs(y));		
	if(dist != 0) {
		incrA = x / dist;		
		incrB = y / dist;	
	}
	for(i=0; i<dist; i++) {
		a0 += incrA;
		b0 += incrB;
		outlet(0, Math.floor(a0+0.5), Math.floor(b0+0.5));
	}
}

function set(c, d) {
	a = c;
	b = d;
}

/* --- end listInterpol.js ---- */



#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 231 87 37 196617 52 74;
#P message 187 87 37 196617 52 72;
#P newex 95 190 61 196617 print outlet;
#P newex 95 162 84 196617 js listInterpol.js;
#P message 143 87 37 196617 52 68;
#P message 95 87 37 196617 49 67;
#P message 35 87 54 196617 set 45 67;
#P comment 27 72 70 196617 set start list;
#P connect 1 0 4 0;
#P connect 2 0 4 0;
#P connect 3 0 4 0;
#P connect 6 0 4 0;
#P connect 7 0 4 0;
#P connect 4 0 5 0;
#P window clipboard copycount 8;


More information about the javascript-dev mailing list