I wanted to post a section of the javascript that I mentioned in the last post because I found it very beautiful and strangely inspiring, almost like 'automatic writing' -- as I mentioned. Of course, if you have never coded this may leave you quite cold:
//Close to an 'end': If timeleft is less than elapsed time
//from last function call
if(ids_sub[k][m+2][7] <= elapsedTicks) {
//These redundant calls are for IE...and everybody else------
//depending on fadestate, opacity set to max or min
element.style.opacity = ids_sub[k][m+2][6] == 1 ?
ids_sub[k][m+2][4]/100 : ids_sub[k][m+2][3]/100;
element.style.filter =
'alpha(opacity = ' + (ids_sub[k][m+2][6] == 1 ?
ids_sub[k][m+2][4] : ids_sub[k][m+2][3]) + ')';
//------------------------------------------------------------
//Flip fade from transp. to opaque, or versa
ids_sub[k][m+2][6] = ids_sub[k][m+2][6] == 1 ? -1 : 1;
//Depending on FadeState, TimeLeft is assigned
//opaque or transparent TimeToFade
ids_sub[k][m+2][7] = ids_sub[k][m+2][6] == 1 ?
ids_sub[k][m+2][1] : ids_sub[k][m+2][2];
//This block is the main animation of the opacity,
//incrementing time left
} else {
//time left incremented down
ids_sub[k][m+2][7] -= elapsedTicks;
if(ids_sub[k][m+2][6] == 1) {
//Timeleft divided by TimeToFade multiplied by difference
//between opacity max, min
var newOpVal = (ids_sub[k][m+2][7]/ids_sub[k][m+2][1])*
((ids_sub[k][m+2][4]-ids_sub[k][m+2][3])/100);
//offset from max. opacity
newOpVal = (ids_sub[k][m+2][4]/100) - newOpVal;
} else {
var newOpVal = (ids_sub[k][m+2][7]/ids_sub[k][m+2][2])*
((ids_sub[k][m+2][4]-ids_sub[k][m+2][3])/100);
//offset by minimum opacity
newOpVal = (ids_sub[k][m+2][3]/100) + newOpVal;
}
//These redundant calls are for IE...and everybody else----------
element.style.opacity = newOpVal;
element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';
//---------------------------------------------------------------
} //end if then else
For those of you who could possibly get something from this: all the abstract array entries are substitutes for functions that used to use word-like names, but which I wanted to store abstractly so I could just modify a template literal array for each comic page and therefore be able to compose each animation as a small series of parameters (combined with some url's for graphic content of course).
Note: for those of you appalled by the indenting...I had to compress it for the blog formatting, it really is a LOT more clear in the original...had to be or I wouldn't understand it one hour after I wrote it!

No comments:
Post a Comment