

Thread Tools  Search this Thread  Display Modes 

18th October 2002, 02:56  #1 
Member
Join Date: Mar 2002
Posts: 92

"layer.fx_" functions and Layer.fx_onGetPixelR() information
I've looked all over, but I haven't found explanations for all the layer.fx_ functions, and especially
code: Does anyone know what they do, or tell me where to find this out? 
18th October 2002, 08:14  #2 
Guest
Posts: n/a

AndrewMackowski, they're nowhere that I've found either, but through some experimenting with DMove and my own stuff, here's what I've found so far. I'm far from an authority on the subject, but this should be enough to get you going. If anyone has any more information about some of these functions I'd be interested too.
fx_setBgFx(0); not exactly sure about this one fx_setBilinear(1); bilinear filtering  smooths stuff out, I think, but doesn't seem to have much (any?) effect fx_setClear(1); not exactly sure about this one  has to do with whether the layer gets drawn in every frame and then the layer fx is applied or if layer fx are applied to the contents of the previous frame  but not exactly... fx_setLocalized(1); not exactly sure about this one fx_setRealtime(1); 0  only seems to update when mouse is over and moving (perhaps when there is any kind of movement over the layerFX? e.g. an animatedLayer) 1  updates every x milliseconds (set by fx_setSpeed) fx_setSpeed(30); milliseconds per frame  higher number => fewer frames per second fx_setWrap(0); 0  uses the image on the layer normaly 1  tiles the image on the layer fx_setRect(0); 0  use fx_onGetPixelR and x_onGetPixelD 1  use fx_onGetPixelX and x_onGetPixelY fx_setAlphaMode(2); 0  don't use fx_onGetPixelA 1  continually call fx_onGetPixelA (like other fx_onGetPixel calls) 2  call fx_onGetPixelA once at the start of the script and use that value throughout fx_setGridSize(4,4); number of squares to divide layer into. i.e. 4x4 == 16 squares fewer squares => better performance more squares => more precise rendering (but CPU hog) Which brings us to the fx_onGetPixel... stuff. These are kind of difficult to explain, but here goes. In general, these are called every time the layerFX is updated at every square defined by fx_setGridSize. If setRect is set, then fx_onGetPixelX and fx_onGetPixelY are called. If not, then fx_onGetPixelR and fx_onGetPixelD are called. fx_onGetPixelA is called depending on how fx_setAlphaMode is set. For all these functions: Polar Coordinates  a point is determined by it's distance (radius) and angle from the origin: r  angle in radians d  disance from origin Rectangular Coordinates  standard x and y coordinate system (cartesian plane) x  x coordinate y  y coordinate a  Alpha value  opacity As near as I can figure out, the origin is always in the center of the layerFX. For each function, Winamp passes you 'starting' coordinates in both polar and rectangular form. Your job is to determine a 'new' value for one these coordinates (or alpha value) depending on the function. For example, with fx_onGetPixelR, you should return a 'new' r value. So, what do these new values do? All they do is translate what was at the 'starting' coordinate to the 'new' coordinate. But because winamp is special, for no extra work for you, the chunck that you just moved will also be squished (highly technical term) morphed, scaled, and whatnot in order to seamlessly blend the other chuncks that you'll be moving about. fx_onGetPixelR(double r, double d, double x, double y) { //Return the new angle here //(remember, in radians: radians = degrees * pi / 180 ) } fx_onGetPixelD(double r, double d, double x, double y) { //Return the new distance from origin here } fx_onGetPixelX(double r, double d, double x, double y) { //Return the new x coordinate here } fx_onGetPixelY(double r, double d, double x, double y) { //Return the new y coordinate here } fx_onGetPixelA(double r, double d, double x, double y) { //Return the alpha value here } For some examples, I suggest looking at DMove (is this still available?) and rotationlayer.m. If I can be of further assistance, just let me know. Good luck! WeAreCS 
18th October 2002, 08:21  #3 
Forum King
Join Date: Mar 2001
Location: irc.tehflap.org/*******
Posts: 3,085

some more documentation :
fx_setEnabled(boolean onoff); // turns the fx layer on or off fx_setRect(Boolean onoff); // if true, you handle fx_onGetPixelX() and fx_onGetPixelY() // if false, you handle fx_onGetPixelR() and fx_onGetPixelD() fx_setBgFx(Boolean onoff); // if true, the layer gets its source pixels from what's underneath // Anything in this layer itself (ie. its bitmap) won't be drawn. // if false, the layer gets its source pixels from itself fx_setAlphaMode(Boolean onoff); // If true, you can handle fx_onGetPixelA() to control // the alpha at points fx_setGridSize(Int x, Int y); // samples at x points on the x axis, y points on the y axis // it interpolates between these points. // *** NOTE: chugs if too big. Set at 10,10 for starters fx_setWrap(Boolean onoff); // Will wrap when getting pixels beyond extent of layer fx_update(); // If you change the "fx" (rotation angle changes, etc.) you // need to call this to redraw the layer. fx_setClear(Boolean onoff); fx_setSpeed(Int msperframe); fx_setRealtime(Boolean onoff); fx_setLocalized(Boolean onoff); fx_setBilinear(Boolean onoff); fx_restart(); // haven't played with this stuff, need more info!!!! // Callbacks [myLayer].fx_onGetPixelX(double r, double d, double x, double y) [myLayer].fx_onGetPixelY(double r, double d, double x, double y) // map the x,y coming in to a different x or y. // the range is x=1..1 lefttoright, y=1..1 toptobottom // *** NOTE: positive Y does DOWN [myLayer].fx_onGetPixelR(double r, double d, double x, double y) [myLayer].fx_onGetPixelD(double r, double d, double x, double y) // map the r,d (polar coordinates) coming in to a different r,d. // the range is r=(pi/2..3pi/2 clockwise from 9 o'clock // *** NOTE: not your usual 0..2pi starting from 3 o'clock, // but essentially radians (2pi of range) // d=0..1 centertocorner // In the above handlers, you return the X,Y,R or D that you want // to get the pixel from // ie. // horizontal mirror, fx_onGetPixelX() should return (1x) // rotate, fx_onGetPixelR() should return (r + angle of rotation) // for a "lens" distortion, fx_onGetPixelD() should scale d so // you return less than d for 00.707, then return d when d>0.707 // such as // if ( d < 0.707 ) // { // return 0.44(0.44*cos(PI*d)); // } // else // { // return d; // } [myLayer].fx_onGetPixelA(double r, double d, double x, double y) // Control the alpha blending of the layer. // return 0.0 to 1.0, full transparent to full opaque. 
20th October 2002, 00:52  #4 
Member
Join Date: Mar 2002
Posts: 92

Wow, actually that's really interestingI wonder why WA3 was designed with two coordinate systemsjust for rotation I guess? Anyways, this makes a LOT more sense now, thanks a lot both of you!

20th October 2002, 05:26  #5 
Major Dude

I'm willing to bet that it doesn't really have two coordinate systems, but rather maps the polar coords to the rectangular.


Thread Tools  Search this Thread 
Display Modes  

