File talk:Peripheral drift.png

This image was made using a script in mathmap plugin for GIMP:

######################################################
#              Peripheral drift illusion             #
# written by Nasca Octavian PAUL, Tg. Mures, Romania #
# http://zynaddsubfx.sourceforge.net                 #
# http://hypermammut.sourceforge.net/paulstretch     #
######################################################
# inspired by "Rotating snakes" illusions by Akiyoshi KITAOKA

# Last modified: 20081114

# PARAMETERS:
#   loops: How many times the pattern is looped on a circle
#   reverse: Reverse the pattern
#   radial: Makes the radial pattern
#   stretch: Radial stretch of the pattern 
#   rotate: Radial rotate of the pattern
#   shear: Shear the pattern
#   space: How much black/white the pattern contains
#   divide_r: Change the pattern direction according to the radius
#   divide_a: Change the pattern direction according to the direction

# todo: 
# Make possible for the user to select the colors. This requires adjusting of
# the lightness of the color (otherwise, no drift illusion will be perceived).

filter rotating_illusion (int loops: 5-100(30),
		      bool reverse(0), 
		      bool radial(1),
                      float stretch: 0.2-5 (1),
                      float rotate: 0-1 (0.5),
		      float shear: -1-1 (0),
                      float space: 0.1-1 (0.5),
		      int divide_r: 1-10 (1),
		      int divide_a:1-10(1)
                      )
   a1=a;
   r1=r;
   if (X<Y) then r1=r1/X; end;  
   if (X>Y) then r1=r1/Y; end;  

   if (radial) then
   	k1=log(r1)*loops*stretch/(loops/8);
   	px0=floor(k1)*rotate;
   	px=loops*a1/(pi*2)-(1-r1)*shear*loops/5+px0;

else
   
   	px=log(r1)*stretch*5;
   	px=px+floor(a1/(pi)*loops)*rotate+(a1/(2*pi)*floor(shear*50));   
end;

  if (divide_r>=2) then
        a2=r*divide_r*0.5;
        dv=a2-floor(a2);
        px=px*sign(dv-0.5);
   end;
   if (divide_a>=2) then
          a2=(a1/(pi*2)+0.25)*(divide_a-1);
          dv=a2-floor(a2);
 	  px=px*sign(dv-0.5);
   end; 
   

   px=px*(1.0-reverse*2);
   px=px-floor(px);

   if (r1>1.0) then
   	grayaColor(0,0);
   else
   if (px<(space*0.25)) then
    	grayColor(0);
   else
   	if (px<0.5) then
		rgbColor(0,0,1);
        else
		if (px<(0.5+space*0.25)) then
			grayColor(1);
             	else
			rgbColor(0.6,0.55,0);
             	end;
        end; 
  end;
  end 
end