GIMP Talk - Community
A premier community of gimp users sharing their knowledge
Welcome PhotoComix . Log out . Account settings. Inbox FAQs (knowledgebase) . Search (results of last search) . New Posts . Contact us

Featured tutorials : Character Artwork and Forest Background by Griatch GimpTalk's Official Free Image Hosting !


Navigation : Board Index > GIMP Plugins, Filters, and Scripts
More Options: Printable version . Email me when replied

Moderation
Post New Topic . Start New Poll . Post reply (quick reply)


Posts of topic : Mathmap 1.20 Codes (only For Mm 1.20)
Author Post details
PhotoComix
Manager




Profile
Send PM


Joined: Jun 13, 2005
Posts: 5328
posted on: Jul 13, 2007 at 12:40:15 EDITDELETELOCK
This topic http://www.gimptalk.com/forum/topic/Mathmap-Codes-17481-1.html start to be too confusing
since are mixed codes for different version of MM ...(older codes will give only error messages on MM 1.20)

Please post (or repost ) here your codes if updated for Mathmap  1.20

how use the code was discussed here http://www.gimptalk.com/forum/topic/Mathmap-Scripts-23077-1.html

°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
(download Mathmap 1.20
for win xp http://gtfoutsider.com/weneedtocleanoutsomeofthesejunkfolders/mathmap.exe
linux package (ubuntu ,fedora..etc) and source on MM webside http://www.complang.tuwien.ac.at/schani/mathmap/
to install in windows ...just double click on the exe )



http://www.flickr.com/photos/97844002@N00/

PhotoComix
Manager




Profile
Send PM


Joined: Jun 13, 2005
Posts: 5328
posted on: Jul 13, 2007 at 12:55:49 EDITDELETELOCK
i start
Here Twist Codes from Gargoyle (Nathan du Gargoyle) as adapted by Josh Sommers (Pisco Bandito)
what follow is the message of Josh Sommers with the codes

Since were technical issue with "CODE" tag ,here the codes are enclosed and separated by lines-------------------------
code start after the lines -------- (and finish before next line ----
)

....................

Ok, here are the converted functions by Nathan DeGargoyle from the first page to function with mathmap 1.2.0.

The formulas are the same, though I cannot vouch for the exact same output. But since the formula is unchaged, the output should be the same too.

 Twist 1
-------------------------------------------------------------------------------------------------------------------------------------------------------
filter twist_one(
     image in,
     int Twists: 1-8 (1))

twist=Twists;

angle = 2*pi*t+twist*pi*x/W;

if sign(y)*y>Y*sign(sin(angle))*sin(angle) then
rgba:[0,0,0,0]
else
ny=y/sin(angle);
in(xy:[x,ny]);
end

end

-----------------------------------------------------------------------------------------------------------------------------------------------------------
EXAMPLE (By Gargoyle))



--------------------------------------------------------------------------------------------------------------------------------------------------------
 Twist 2
----------------------------------------------------------------------------------------------------------------------------------------------------
filter twist_two(
     image in,
     int Spread: 1-1000 (1))


spread=Spread;
ss=t*(W+spread)-W/2;
se=ss-spread;
angle =pi/2+2*pi*(x-se)/spread;

if x>=se then
if x<ss then
     if sign(y)*y>Y*sign(sin(angle))*sin(angle) then
rgba:[0,0,0,0]
     else
ny=y/sin(angle);
in(xy:[x,ny])
     end
else
     in(xy:[x,y])
end
else
in(xy:[x,y])
end

end
-------------------------------------------------------------------------------------------------------------------------------------
EXAMPLE (By Gargoyle))


---------------------------------------------------------------------------------------------------------------------------------------

 Twist 3
------------------------------------------------------------------------------------------------------------------------------------------
filter twist_three(
     image in,
     int Spread: 1-400 (1))

if (t<0.5) then
qt=2*t;
else
qt=2-2*t;
end;

spread=Spread;
ss=qt*(W+spread)-W/2;
se=ss-spread;
angle =pi/2+2*pi*(x-se)/spread;

if x>=se then
if x<ss then
if sign(y)*y>Y*sign(sin(angle))*sin(angle) then
rgba:[0,0,0,0]
else
ny=y/sin(angle);
in(xy:[x,ny])
end
else
in(xy:[x,y])
end
end

end
--------------------------------------------------------------------------------------------------------
EXAMPLE (By Gargoyle))


----------------------------------------------------------------------------------------------------------------------------------
 
Twist 4

-----------------------------------------------------------------------------------------------------------------------------------------------------------
filter twist_four(image in)

if (t<0.5)
then qt=t;
sn=1;
else
qt=t-0.5;
sn=-1;
end;

ss=4*qt*W-W/2;
se=ss-W;
angle =pi/2+pi*(x-se)/W;

if x>=se then
if x<ss then
if sign(y)*y>Y*sign(sin(angle))*sin(angle) then
rgba:[0,0,0,0]
else
ny=-sn*y/sin(angle);
in(xy:[x,ny])
end
else
ny=sn*y;
in(xy:[x,ny])
end
else
ny=-sn*y;
in(xy:[x,ny])
end

end
----------------------------------------------------------------------------------------------

Then , if possible please add a example...here ,as example of twist code i used the sig from PhotoMaster






http://www.flickr.com/photos/97844002@N00/

PhotoMaster
Member




Profile
Send PM


Joined: May 15, 2006
Posts: 528
posted on: Jul 13, 2007 at 07:47:50 EDITDELETELOCK
Thank You so much! The confusion you are ending is mine!

Greg



My Sigs = My Photos

PhotoComix
Manager




Profile
Send PM


Joined: Jun 13, 2005
Posts: 5328
posted on: Jul 14, 2007 at 11:06:09 EDITDELETELOCK
 STEREOGRAPHIC PROJECTION From Gargoyle
-----------------------------------------------------------------------------------------------------------------------------------------------------------

filter StereoNdeG (image in, float sc: 0-4 (1), color back)
rho=sc*r;
radius=Y;
if r>Y then
back;
else
maxpi=2*atan(sc);
colat=2*atan(rho/radius);
long=a;
ny=(Y)*(2*colat/maxpi)-(Y);
nx=(X-1)*long/pi-X;
in(xy:[nx,ny]);
end
end

------------------------------------------------------------------------------------------------------------------------------------------------------------------
  STEREOGRAPHIC PROJECTION variant from VMOS
-------------------------------------------------------------------------------------------------------------------------------------------------------------------

##working stereo 1.13 inc zoom, twist, warp
## Original by Nathan de gargoyle, mangled by VMOS
filter StereoNdeG (image in, float turn: 0-1 (0.00), float zoom: 0-5
(1.00), float sc: 0-4 (1), float warp: 0-3.141592, color back)

zeta=-sin(warp)*1+cos(warp);
rho=sc*r;
radius=Y*zoom;
if r>radius then
back;
else
maxpi=2*atan(sc);
colat=2*atan(rho/radius);
long=(a+2*pi*turn)%(2*pi);
ny=((Y)*(2*colat/maxpi)-(Y));
nx=(X-1)*long/pi-X;
in(xy:[nx,ny*zeta]);
end
end
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

takes



Doubled horizontally

To



Example by Gargoyle

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------



http://www.flickr.com/photos/97844002@N00/

PhotoMaster
Member




Profile
Send PM


Joined: May 15, 2006
Posts: 528
posted on: Jul 15, 2007 at 12:30:37 EDITDELETELOCK
I would love to take credit for this code, but I can't. I had absolutely nothing to do with it other than wanting everyone to have it. It is awesome.

Greg

 Doste V.9

Originally by breic ( www.flickr.com/photos/breic )
# Additional Features and Mathmap 1.2 conversion by Josh Sommers (www.flickr.com/photos/joshsommers) #
-------------------------------------------------------------------------------------------------------------------------------------------------------


######################################################################################################
# Droste effect code version 9 for Mathmap 1.2.0 #
# Originally by breic ( www.flickr.com/photos/breic ) #
# Additional Features and Mathmap 1.2 conversion by Josh Sommers (www.flickr.com/photos/joshsommers) #
# See also the flickr group: www.flickr.com/groups/escherdroste #
# Last modified: 6/10/2007 #
######################################################################################################

#Decription of User Values:
#InnerRadius: The percentage of the overall image that you want to be occupied by the spiral.
#OuterRadius: The percentage size of the overall image that you want to use in the effect.
#Periodicity: The number of times the image is repeated on each iteration of the spiral.
#Strands: The number of strands/arms the spiral will have.
#Zoom: Zoom in or out of the spiral.
#Rotate: Rotate the spiral. Positive numbers rotate clockwise.
#XShift: Shift the image on the X axis. Positive numbers shift to the right.
#YShift: Shift the image on the Y axis. Positive numbers shift upwards.
#XCenterShift: Shift the center of the spiral on the X axis. Positive numbers shift to the right.
#YCenterShift: Shift the center of the spiral on the Y axis. Positive numbers shift upwards.
#StartingLevel: The level that the spiral starts at. For internal transparency or no transparency, the first level is the outermost level. For outer transparency, the first level is the innermost level.
#NumberOfLevels: The total number of repetitions of the spiral.
#LevelFrequency: The frequency of levels. If set at 1, you will get every level. If set at 2 you will get every other level. If set at 3 you will get every third level, and so on.
#AutoSetPeriodicity: If set to true, the optimal value for Periodicity will be set for you.
#NoTransparency: Set to true if you do not wish to tile based upon a transparent region in your image.
#ExternalTransparency: Set the to true if the transparent region is on the outside of the image. The default is false, indicating that the transparent region is on the inside of the image.
#MirroEffect: Only works when using multiple strands. Set to true to mirror strands.
#Untwist: Set to true to see the image in log coordinates.
#DoNotFlattenTransparency: Set to true to leave semi-transparent pixels semi-transparent.
#Show Grid: The green grid shows each basic annulus, with (outer radius)/(inner radius) = r2/r1. The blue grid shows the green grid mapped into log coordinates (in which it truly is a grid), rotated, and exponentiated forward again. This allows visualization of the Droste transformation.
#ShowFrame: The frame is a black-and-white border in the standard view, and its preimage in the log coordinates. In log coordinates, the shaded region to the right of the frame will be mapped outside the viewport, while the region to the left will be visible.

############################################################
## You should not need to change anything below this line ##
############################################################

filter droste (
image in,
int InnerRadius: 1 - 100 (25),
int OuterRadius: 1 - 100 (100),
float Periodicity: -6 - 6 (1),
int Strands: -6 - 6 (1),
int Zoom: 1-100 (1),
int Rotate: -360-360 (0),
int XShift: -100 - 100 (0),
int YShift: -100 - 100 (0),
int XCenterShift: -100 - 100 (0),
int YCenterShift: -100 - 100 (0),
int StartingLevel: 1-20 (1),
int NumberOfLevels: 1-20 (10),
int LevelFrequency: 1-10 (1),
bool AutoSetPeriodicity,
bool NoTransparency,
bool ExternalTransparency,
bool MirrorEffect,
bool Untwist,
bool DoNotFlattenTransparency,
bool ShowGrid,
bool ShowFrame)


#Set code variables from user variables
r1= InnerRadius/100;
r2= OuterRadius/100;
p1= Periodicity;
p2= Strands;
xCenterShift = XCenterShift/100;
yCenterShift = YCenterShift/100;
xShift = (XShift*W/X)/100;
yShift = (YShift*H/Y)/100;
tileBasedOnTransparency = !(NoTransparency);
transparentPointsIn = !(ExternalTransparency);
levelsToLookOut=StartingLevel;
levelToShow=LevelFrequency;
retwist=!(Untwist);

if (AutoSetPeriodicity) then
p1= p2/2 * (1+sqrt(1-(log(r2/r1)/pi)^2));
end;

#Set Rotation
if p1 > 0 then
rotate=-(pi/180) * Rotate;
else
rotate=(pi/180) * Rotate;
end;

#Set Zoom
zoom=(Zoom+InnerRadius-1)/100;

epsilon=.01;

#######################
# Set up the viewport #
#######################
if (retwist) then
xbounds=[-r2,r2];
ybounds=[-r2,r2];
else
ybounds=[0,2.1*pi];
xbounds=[-log(r2/r1), log(r2/r1)];
end;

minDimension=min(W, H);
xymiddle=ri:[0.5*(xbounds[0]+xbounds[1]),0.5*(ybounds[0]+ybounds[1])];
xyrange=xy:[xbounds[1]-xbounds[0], ybounds[1]-ybounds[0]];
aspectRatio=W/H;
xyrange[0]=xyrange[1]*aspectRatio;
xbounds=[xymiddle[0]-0.5*xyrange[0],xymiddle[0]+0.5*xyrange[0]];
z=ri:[xbounds[0]+(xbounds[1]-xbounds[0])*(x+W/2)/W,ybounds[0]+(ybounds[1]-ybounds[0])*(y+H/2)/H];



# only allow for procedural zooming/scaling in the standard coordinates
if (retwist) then
zinitial=z;
z = z - ri:[xShift,yShift];
z=xymiddle+(z-xymiddle)/zoom*exp(-I*rotate);
else
zinitial=r1*exp(z); # save these coordinates for drawing a frame later
zinitial=zinitial*Zoom*exp(I*rotate);
end;

if (retwist) then
z2=log(z/r1);
else
z2 = z;
end;

##################################
# Droste-effect math starts here #
##################################

alpha=atan(p2/p1*log(r2/r1)/(2*pi));
f=cos(alpha);
beta=f*exp(I*alpha);

# the angle of rotation between adjacent annular levels
if (p2 > 0)
then angle = 2*pi*p1;
else
angle =-2*pi*p1;
end;

if MirrorEffect then
angle=angle/Strands;
end;

z=p1*z2/beta;
rotatedscaledlogz=z; # save these coordinates for drawing a grid later
logz=z2; # save these coordinates for drawing a grid later
z=r1*exp(z);

################################
# Droste-effect math ends here #
################################

if (tileBasedOnTransparency && levelsToLookOut > 0) then
if (!transparentPointsIn) then ratio=r2/r1*exp( I*angle); end;
if ( transparentPointsIn) then ratio=r1/r2*exp(-I*angle); end;
z = z * (ratio^levelsToLookOut)/1;
end;

colorSoFar=rgba:[0,0,0,0];
alphaRemaining=1;
ix=minDimension/2*(z[0]+xCenterShift);
iy=minDimension/2*(z[1]+yCenterShift);
iXY = xy:[ix,iy];

ColorOut=in(iXY);
colorSoFar = colorSoFar = colorSoFar + (ColorOut*(alpha(ColorOut)*alphaRemaining));
alphaRemaining=alphaRemaining*(1-alpha(ColorOut));
sign=0;

if (tileBasedOnTransparency) then
if ( transparentPointsIn && alphaRemaining > epsilon) then
sign=-1;
end;
if (!transparentPointsIn && alphaRemaining > epsilon) then
sign= 1;
end;
else
radius=sqrt(z[0]*z[0]+z[1]*z[1]);
if (radius < r1) then sign=-1; end;
if (radius > r2) then sign= 1; end;
end;

if (sign < 0) then
ratio=r2/r1*exp( I*angle);
end;

if (sign > 0) then
ratio=r1/r2*exp(-I*angle);
end;

if (levelToShow > 1) then
ratio = exp(log(ratio)*levelToShow);
end;

iteration=StartingLevel;
maxiteration=NumberOfLevels+StartingLevel-1;

while (sign != 0 && iteration < maxiteration) do
z2=z*ratio;
z=z2;
rotatedscaledlogz=rotatedscaledlogz+ri:[0,-sign*angle];
ix=minDimension/2*(z[0]+xCenterShift);
iy=minDimension/2*(z[1]+yCenterShift);
iXY = xy:[ix,iy];
sign=0;
if (tileBasedOnTransparency) then
ColorOut=in(iXY);
colorSoFar = colorSoFar + (ColorOut*(alpha(ColorOut)*alphaRemaining));
alphaRemaining=alphaRemaining*(1-alpha(ColorOut));
if ( transparentPointsIn && alphaRemaining > epsilon) then sign=-1; end;
if (!transparentPointsIn && alphaRemaining > epsilon) then sign= 1; end;
else
radius=sqrt(z[0]*z[0]+z[1]*z[1]);
colorSoFar=in(iXY);
if (radius < r1) then sign=-1; end;
if (radius > r2) then sign= 1; end;
end;
iteration=iteration+1;
end;

ColorOut=colorSoFar;

if (ShowGrid) then
gridz=xy:[(logz[0]+10*log(r2/r1))%log(r2/r1), (logz[1]+10*2*pi)%(2*pi)];

if (gridz[0] < epsilon || gridz[0] > (log(r2/r1)-epsilon) || gridz[1] < epsilon || gridz[1] > (2*pi-epsilon)) then
ColorOut=rgba:[0,1,0,1];
end;

gridz=xy:[(rotatedscaledlogz[0]+10*log(r2/r1))%log(r2/r1), (rotatedscaledlogz[1]+10*2*pi)%(2*pi)];

if (gridz[0] < epsilon || gridz[0] > (log(r2/r1)-epsilon) || gridz[1] < epsilon || gridz[1] > (2*pi-epsilon)) then ColorOut=rgba:[0,0,1,1];
end;
end;

if (ShowFrame) then
gridz=xy:[zinitial[0],zinitial[1]];
if (gridz[0] < (aspectRatio*r2) && gridz[0] > -(aspectRatio*r2) && gridz[1] < r2 && gridz[1] > -r2) then
dx=min((aspectRatio*r2)-gridz[0], gridz[0]+(aspectRatio*r2));
dy=min(r2-gridz[1], gridz[1]+r2);
if (dx < (4*epsilon) || dy < (4*epsilon)) then
ColorOut=rgba:[1,1,1,1];
end;
if (dx < (2*epsilon) || dy < (2*epsilon)) then
ColorOut=rgba:[0,0,0,1];
end;
else
ColorOut=rgba:[0.75*red(ColorOut),0.75*green(ColorOut),0.75*blue(ColorOut),1];
end;
end;

if !(DoNotFlattenTransparency) then
ColorOut=rgba:[ColorOut[0], ColorOut[1], ColorOut[2], 1];
end;

ColorOut

end

-------------------------------------------------------------------------------------------------------------------------------------------------------

The result would be something like this.




My Sigs = My Photos

PhotoMaster
Member




Profile
Send PM


Joined: May 15, 2006
Posts: 528
posted on: Jul 15, 2007 at 12:35:12 EDITDELETELOCK
This code I would like to take credit for, too. But again I can't. All I did was to add some variables to animate the effect. I'm still working on improving it. I've got rotation working but getting variations on zoom have been unsuccessful.

Greg
 Doste V.9 Animated
-------------------------------------------------------------------------------------------------------------------------------------------------------

######################################################################################################
# Droste effect code version 9 for Mathmap 1.2.0 #
# Originally by breic ( www.flickr.com/photos/breic ) #
# Additional Features and Mathmap 1.2 conversion by Josh Sommers (www.flickr.com/photos/joshsommers) #
# See also the flickr group: www.flickr.com/groups/escherdroste #
# Last modified: 6/10/2007 #
######################################################################################################

#Decription of User Values:
#InnerRadius: The percentage of the overall image that you want to be occupied by the spiral.
#OuterRadius: The percentage size of the overall image that you want to use in the effect.
#Periodicity: The number of times the image is repeated on each iteration of the spiral.
#Strands: The number of strands/arms the spiral will have.
#Zoom: Zoom in or out of the spiral.
#Rotate: Rotate the spiral. Positive numbers rotate clockwise.
#XShift: Shift the image on the X axis. Positive numbers shift to the right.
#YShift: Shift the image on the Y axis. Positive numbers shift upwards.
#XCenterShift: Shift the center of the spiral on the X axis. Positive numbers shift to the right.
#YCenterShift: Shift the center of the spiral on the Y axis. Positive numbers shift upwards.
#StartingLevel: The level that the spiral starts at. For internal transparency or no transparency, the first level is the outermost level. For outer transparency, the first level is the innermost level.
#NumberOfLevels: The total number of repetitions of the spiral.
#LevelFrequency: The frequency of levels. If set at 1, you will get every level. If set at 2 you will get every other level. If set at 3 you will get every third level, and so on.
#AutoSetPeriodicity: If set to true, the optimal value for Periodicity will be set for you.
#NoTransparency: Set to true if you do not wish to tile based upon a transparent region in your image.
#ExternalTransparency: Set the to true if the transparent region is on the outside of the image. The default is false, indicating that the transparent region is on the inside of the image.
#MirroEffect: Only works when using multiple strands. Set to true to mirror strands.
#Untwist: Set to true to see the image in log coordinates.
#DoNotFlattenTransparency: Set to true to leave semi-transparent pixels semi-transparent.
#Show Grid: The green grid shows each basic annulus, with (outer radius)/(inner radius) = r2/r1. The blue grid shows the green grid mapped into log coordinates (in which it truly is a grid), rotated, and exponentiated forward again. This allows visualization of the Droste transformation.
#ShowFrame: The frame is a black-and-white border in the standard view, and its preimage in the log coordinates. In log coordinates, the shaded region to the right of the frame will be mapped outside the viewport, while the region to the left will be visible.

############################################################
## You should not need to change anything below this line ##
############################################################

filter droste (
image in,
float InnerRadius: 1 - 100 (25),
float OuterRadius: 1 - 100 (100),
float Periodicity: -6 - 6 (1),
int Strands: -6 - 6 (1),
float Zoom: 1 -100 (1),
float Rotate: -360-360 (0),
int XShift: -100 - 100 (0),
int YShift: -100 - 100 (0),
int XCenterShift: -100 - 100 (0),
int YCenterShift: -100 - 100 (0),
int StartingLevel: 1-20 (1),
int NumberOfLevels: 1-20 (10),
int LevelFrequency: 1-10 (1),
bool AutoSetPeriodicity,
bool NoTransparency,
bool ExternalTransparency,
bool MirrorEffect,
bool Untwist,
bool DoNotFlattenTransparency,
bool ShowGrid,
bool ShowFrame)



#Set code variables from user variables
r1= ((InnerRadius*(1+t))/100);
r2= ((OuterRadius*(1+t))/100);
p1= (Periodicity);
p2= (Strands);
xCenterShift = XCenterShift/100;
yCenterShift = YCenterShift/100;
xShift = (XShift*W/X)/100;
yShift = (YShift*H/Y)/100;
tileBasedOnTransparency = !(NoTransparency);
transparentPointsIn = !(ExternalTransparency);
levelsToLookOut=StartingLevel;
levelToShow=LevelFrequency;
retwist=!(Untwist);

if (AutoSetPeriodicity) then
p1= p2/2 * (1+sqrt(1-(log(r2/r1)/pi)^2));
end;

#Set Rotation
if p1 > 0 then
rotate=-(pi/180) * (Rotate + (t*360));
else
rotate=(pi/180) * (Rotate + (t*360));
end;

#Set Zoom
zoom=(Zoom+InnerRadius-1)/100;

epsilon=.01;

#######################
# Set up the viewport #
#######################

if (retwist) then
xbounds=[-r2,r2];
ybounds=[-r2,r2];
else
ybounds=[0,2.1*pi];
xbounds=[-log(r2/r1), log(r2/r1)];
end;

minDimension=min(W, H);
xymiddle=ri:[0.5*(xbounds[0]+xbounds[1]),0.5*(ybounds[0]+ybounds[1])];
xyrange=xy:[xbounds[1]-xbounds[0], ybounds[1]-ybounds[0]];
aspectRatio=W/H;
xyrange[0]=xyrange[1]*aspectRatio;
xbounds=[xymiddle[0]-0.5*xyrange[0],xymiddle[0]+0.5*xyrange[0]];
z=ri:[xbounds[0]+(xbounds[1]-xbounds[0])*(x+W/2)/W,ybounds[0]+(ybounds[1]-ybounds[0])*(y+H/2)/H];



# only allow for procedural zooming/scaling in the standard coordinates
if (retwist) then
zinitial=z;
z = z - ri:[xShift,yShift];
z=xymiddle+(z-xymiddle)/zoom*(t+1)*exp(-I*rotate);
else
zinitial=r1*exp(z); # save these coordinates for drawing a frame later
zinitial=zinitial*Zoom*(t+1)*exp(I*rotate);
end;

if (retwist) then
z2=log(z/r1);
else
z2 = z;
end;

##################################
# Droste-effect math starts here #
##################################

alpha=atan(p2/p1*log(r2/r1)/(2*pi));
f=(cos(alpha));
beta=f*exp(I*alpha);

# the angle of rotation between adjacent annular levels
if (p2 > 0)
then angle = 2*pi*p1;
else
angle =-2*pi*p1;
end;

if MirrorEffect then
angle=angle/Strands;
end;

z=p1*z2/beta;
rotatedscaledlogz=z; # save these coordinates for drawing a grid later
logz=z2; # save these coordinates for drawing a grid later
z=r1*exp(z);


################################
# Droste-effect math ends here #
################################

if (tileBasedOnTransparency && levelsToLookOut > 0) then
if (!transparentPointsIn) then ratio=r2/r1*exp( I*angle); end;
if ( transparentPointsIn) then ratio=r1/r2*exp(-I*angle); end;
z = z * (ratio^levelsToLookOut)/1;
end;

colorSoFar=rgba:[0,0,0,0];
alphaRemaining=1;
ix=minDimension/2*(z[0]+xCenterShift);
iy=minDimension/2*(z[1]+yCenterShift);
iXY = xy:[ix,iy];

ColorOut=in(iXY);
colorSoFar = colorSoFar = colorSoFar + (ColorOut*(alpha(ColorOut)*alphaRemaining));
alphaRemaining=alphaRemaining*(1-alpha(ColorOut));
sign=0;

if (tileBasedOnTransparency) then
if ( transparentPointsIn && alphaRemaining > epsilon) then
sign=-1;
end;
if (!transparentPointsIn && alphaRemaining > epsilon) then
sign= 1;
end;
else
radius=sqrt(z[0]*z[0]+z[1]*z[1]);
if (radius < r1) then sign=-1; end;
if (radius > r2) then sign= 1; end;
end;

if (sign < 0) then
ratio=r2/r1*exp( I*angle);
end;

if (sign > 0) then
ratio=r1/r2*exp(-I*angle);
end;

if (levelToShow > 1) then
ratio = exp(log(ratio)*levelToShow);
end;

iteration=StartingLevel;
maxiteration=NumberOfLevels+StartingLevel-1;


while (sign != 0 && iteration < maxiteration) do
z2=z*ratio;
z=z2;
rotatedscaledlogz=rotatedscaledlogz+ri:[0,-sign*angle];
ix=minDimension/2*(z[0]+xCenterShift);
iy=minDimension/2*(z[1]+yCenterShift);
iXY = xy:[ix,iy];
sign=0;
if (tileBasedOnTransparency) then
ColorOut=in(iXY);
colorSoFar = colorSoFar + (ColorOut*(alpha(ColorOut)*alphaRemaining));
alphaRemaining=alphaRemaining*(1-alpha(ColorOut));
if ( transparentPointsIn && alphaRemaining > epsilon) then sign=-1; end;
if (!transparentPointsIn && alphaRemaining > epsilon) then sign= 1; end;
else
radius=sqrt(z[0]*z[0]+z[1]*z[1]);
colorSoFar=in(iXY);
if (radius < r1) then sign=-1; end;
if (radius > r2) then sign= 1; end;
end;
iteration=iteration+1;
end;

ColorOut=colorSoFar;

if (ShowGrid) then
gridz=xy:[(logz[0]+10*log(r2/r1))%log(r2/r1), (logz[1]+10*2*pi)%(2*pi)];

if (gridz[0] < epsilon || gridz[0] > (log(r2/r1)-epsilon) || gridz[1] < epsilon || gridz[1] > (2*pi-epsilon)) then
ColorOut=rgba:[0,1,0,1];
end;

gridz=xy:[(rotatedscaledlogz[0]+10*log(r2/r1))%log(r2/r1), (rotatedscaledlogz[1]+10*2*pi)%(2*pi)];

if (gridz[0] < epsilon || gridz[0] > (log(r2/r1)-epsilon) || gridz[1] < epsilon || gridz[1] > (2*pi-epsilon)) then ColorOut=rgba:[0,0,1,1];
end;
end;

if (ShowFrame) then
gridz=xy:[zinitial[0],zinitial[1]];
if (gridz[0] < (aspectRatio*r2) && gridz[0] > -(aspectRatio*r2) && gridz[1] < r2 && gridz[1] > -r2) then
dx=min((aspectRatio*r2)-gridz[0], gridz[0]+(aspectRatio*r2));
dy=min(r2-gridz[1], gridz[1]+r2);
if (dx < (4*epsilon) || dy < (4*epsilon)) then
ColorOut=rgba:[1,1,1,1];
end;
if (dx < (2*epsilon) || dy < (2*epsilon)) then
ColorOut=rgba:[0,0,0,1];
end;
else
ColorOut=rgba:[0.75*red(ColorOut),0.75*green(ColorOut),0.75*blue(ColorOut),1];
end;
end;

if !(DoNotFlattenTransparency) then
ColorOut=rgba:[ColorOut[0], ColorOut[1], ColorOut[2], 1];
end;

ColorOut

end

-------------------------------------------------------------------------------------------------------------------------------------------------------

The result would be something like this.


or


 The difference between the two was simply reversing the order of the layers.



My Sigs = My Photos

PhotoComix
Manager




Profile
Send PM


Joined: Jun 13, 2005
Posts: 5328
posted on: Jul 16, 2007 at 10:26:38 EDITDELETELOCK
---------------------------------------------------------------------------------------------------------------------------
 KALEIDOSCOPE by Nathan Du Gargoyle

--------------------------------------------------------------------------------------------------------------------------------------------------------------
filter kaleidoscope (image in, int ng: 2-10, float rot: 0-6.28318, int sx: 0-2000, int sy: 0-2000, float rad: 0-100)
intang=2*pi/ng;na=a+pi/2;
ang=intang/2-na%intang;
ang=rot+(intang/2-sqrt(ang^2));
xr=r*rad;
rad=rad*min(X,Y);
if xr<rad then
nr=xr;
else
ang=2*ang;
nr=rad*xr/R;
end;
nx=nr*cos(ang);
ny=nr*sin(ang);
nx=(nx+sx)%(W-1)-(X-1);
ny=(ny+sy)%(H-1)-(Y-1);
in(xy:[nx,ny])
end
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

Example...

Umh i must find the original...however that is a example ...they was just some kind of algae before...

PhotoComix
Manager




Profile
Send PM


Joined: Jun 13, 2005
Posts: 5328
posted on: Jul 17, 2007 at 05:07:24 EDITDELETELOCK
I tried to add animation to the original Sphere script (original from Herbert Poetzl, is included in Mathmap (see Mathmap/map/ sphere, and is not related with the other script with the same name in Mathmap /distort/sphere)

Then nothing worked out so i ask support to Gargoyle and Josh Sommers

This is the first working version from Gargoyle
-------------------------------------------------------------------------------------------------------------------------------------------------------------

 ANIMATED SPHERE adapted for animation by
Nathan de Gargoyle

-----------------------------------------------------------------------------------------------------------------------------------------

]# by Herbert Poetzl
# adapted for animation by Nathan deGargoyle
# rota, rotb, rotg are the rotation speeds in the x,y, and z planes.
filter sphere (image in,
float alphas: 0-6.2831853, float betas: 0-6.2831853,
float gammas: 0-6.2831853, int rota: 0-10,
          int rotb: 0-10, int rotg: 0-10, color background)
rd=0.9*min(X,Y);
if r>rd then
background
else
     alpha=alphas+rota*t*6.2831853;
     beta=betas+rotb*t*6.2831853;
     gamma=gammas+rotg*t*6.2831853;
sa=sin(alpha);
sb=sin(beta);
ca=cos(alpha);
cb=cos(beta);
theta=a;
phi=acos(r/rd);
x0=cos(theta)*cos(phi);
y0=sin(theta)*cos(phi);
z0=sin(phi);
x1=ca*x0+sa*y0;
z1=-sa*-sb*x0+ca*-sb*y0+cb*z0;
if z1 >= 0 || 1 then
y1=cb*-sa*x0+cb*ca*y0+sb*z0
else
z1=z1-2*cb*z0;
y1=cb*-sa*x0+cb*ca*y0-sb*z0
end;
theta1=atan(-x1/y1)+(if y1>0 then pi/2 else 3*pi/2 end);
phi1=asin(z1);
in(xy:[((theta1*2+gamma)%(2*pi)-pi)/pi*X,-phi1/(pi/2)*Y])
end
end


---------------------------------------------------------------------------------------------------------------------------------------------
EXAMPLE

this has rota=1, rotb=2, rotg=3




http://www.flickr.com/photos/97844002@N00/

PhotoMaster
Member




Profile
Send PM


Joined: May 15, 2006
Posts: 528
posted on: Jul 19, 2007 at 03:15:32 EDITDELETELOCK
Hey PhotoComix,
I assume your sig is mathmapped. What code did you use for that effect?

Greg



My Sigs = My Photos

PhotoComix
Manager




Profile
Send PM


Joined: Jun 13, 2005
Posts: 5328
posted on: Jul 19, 2007 at 03:31:52 EDITDELETELOCK
that is Animated Sphere from Gargoyle -Pisco Bandito...then i distort the sphere scaling down the high of the whole imagine

That is effect of zooming out in combine mode.

Some other possible effects (there with no distortions are posted here http://www.gimptalk.com/forum/topic/Photographic-Ball-22969-1.html (warning for dial up....)

latest series done with a slightly hacked version ...i will post both the codes (the Josh Sommer_Pisco Bandito version and my little hack )later on today.

EDIT
It work so well also because the original landscape was equirectangolar so it could spin seamlessy...is not strictly needed to use eqirectangolar original but a horizontal or vertical (if the shere spin mostly in horizontally or vertically) simmetry avoid break when the sphere loops



http://www.flickr.com/photos/97844002@N00/

PhotoComix
Manager




Profile
Send PM


Joined: Jun 13, 2005
Posts: 5328
posted on: Jul 19, 2007 at 04:46:41 EDITDELETELOCK
Here the original message from Josh Sommers with its version of the Animation Sphere
--------------------------------------------------------------------------------------------------------------------------------------

Here is an updated version of the sphere code that includes some adjustments for the names of variables and their ranges. Also added the ability to set a starting and ending zoom so you can animate a zoom.

----------------------------------------------------------------------------------------------------------------------------------------------
 ANIMATED SPHERE as adapted by Josh Sommers,
------------------------------------------------------------------------------------------------------------------------------------------------------
#Spere Filter
#Originally by Herbert Poetzl
#Adapted for animation by Nathan deGargoyle
#Further Adaptation by Josh Sommers (Pisco Bandito)

#RotateX_Start is the starting rotation on the X axis
#RotateY_Start is the starting rotation on the Y axis
#RotateZ_Start is the starting rotation on the Z axis

#RotateX_End is the ending rotation on the X axis
#RotateY_End is the ending rotation on the Y axis
#RotateZ_End is the ending rotation on the Z axis

#LoopX is the number of times to repeat the rotation specified by RotateX_End.
#LoopY is the number of times to repeat the rotation specified by RotateX_End.
#LoopZ is the number of times to repeat the rotation specified by RotateX_End.

#Loop example:
#If you set RotateX_End to 360 and LoopX to 10 the sphere will rotate 360 degrees on the X axis ten times.
#If you set RotateX_End to 180 and LoopX to 10, then sphere will rotate 360 degrees on the X axis 5 times.

#Zoom_Start is the starting zoom
#Zoom_End is the ending zoom

#Background is the color to use for the background
#BackgroundOpacity is the opacity of the background, 0 for transparent, 100 for opaque. Your image must have an alpha channel for this to work.

############################################################

filter Sphere (image in,
     int RotateX_Start: 0-360 (90),
     int RotateY_Start: 0-360 (90),
     int RotateZ_Start: 0-360 (0),      
     int RotateX_End: 0-360,
     int RotateY_End: 0-360,
     int RotateZ_End: 0-360,
     int LoopX: 1-100(1),
     int LoopY: 1-100(1),
     int LoopZ: 1-100(1),
     int Zoom_Start: 1-300 (100),
     int Zoom_End: 1-300 (100),
     bool Flip_X,
     bool Flip_Y,
int BackgroundOpacity: 0-100 (100),
     color background)

rd=min(X,Y)*((Zoom_Start/100)+(t*(Zoom_End-Zoom_Start)/100));

if r>rd then
rgba:[background[0],background[1],background[2],BackgroundOpacity/100];
else

beta = (pi/180) * RotateX_Start + (pi/180)*(RotateX_End*LoopX*t);
gamma = (pi/180) * RotateY_Start + (pi/180)*(RotateY_End*LoopY*t);
alpha = (pi/180) * RotateZ_Start + (pi/180)*(RotateZ_End*LoopZ*t);     

sa=sin(alpha);
sb=sin(beta);
ca=cos(alpha);
cb=cos(beta);

theta=a;
phi=acos(r/rd);

x0=cos(theta)*cos(phi);
y0=sin(theta)*cos(phi);
z0=sin(phi);
x1=ca*x0+sa*y0;
z1=(-sa*-sb*x0)+(ca*-sb*y0+cb*z0);


if z1 >= 0 || 1 then
y1=cb*-sa*x0+cb*ca*y0+sb*z0;
else
z1=z1-2*cb*z0;
y1=cb*-sa*x0+cb*ca*y0-sb*z0;
end;

theta1=atan(-x1/y1)+(if y1>0 then pi/2 else 3*pi/2 end);
phi1=asin(z1);

ix = ((theta1*1+gamma)%(2*pi)-pi)/pi*X;
iy = -phi1/(pi/2)*Y;

if Flip_X then
ix = -ix
end;

if Flip_Y then
iy= -iy
end;

in(xy:[ix,iy])
end

end

Example

PhotoComix
Manager




Profile
Send PM


Joined: Jun 13, 2005
Posts: 5328
posted on: Jul 19, 2007 at 05:06:18 EDITDELETELOCK
I only changed the range of few values adding a simmetrical negative range.
Then if negative values are used,animation could become jerky, and weird thing could happen.

But i found a couple of this "weird things" interesting ( as showed in examples) so i left the possibilty to input negative values.

For the rest this code is identical to the Pisco Bandito-Josh Sommers version

i would like add a pop out warning about how use that values but i have no idea if possible

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 ANIMATED SPHERE just a minor ,tricky hack by PhotoComiX ,
strictly based on Pisco Bandito -Gargoyle codes
--------------------------------------------------------------------------------------------------------------------------------------------------------------------



-------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

#Sphere Filter

#Originally by Herbert Poetzl

#Adapted for animation by Nathan deGargoyle

#Further Adaptation by Josh Sommers (Pisco Bandito)

# Badly edited by PhotoComiX to add a couple of effects



#RotateX_Start is the starting rotation on the X axis

#RotateY_Start is the starting rotation on the Y axis

#RotateZ_Start is the starting rotation on the Z axis



#Add_RotateX this value is added to RotateX_Start

#Add_RotateY this value is added i to #RotateY_Start

#Add_RotateZ this value is added to Start_RotationZ

#Negative values for "Add_Rotate" allow to invert direction as from 340° to 10° ,"flip" could do it much better
# then if by adding negative values the value of alfa, gamma or zeta become negative results willl be weird




#Multiply_X is the number of times to multply the rotation specified by RotateX_End.

#Multyply_Y is the number of times to multiply the rotation specified by RotateX_End.

#Multiply_Z is the number of times to multiply the rotation specified by RotateX_End.



#Mulltiply example:

#If you set Add_RotateX to 360 and Multiply_X to 10 the sphere will rotate 360 degrees on the X axis ten times.

#If you set Add_RotateX_ to 180 and Multiply_X to 10, then sphere will rotate 360 degrees on the X axis 5 times.



#Zoom_Start is the starting zoom

#Add_Zoom_ This value is added to the Zoom_Start value



#Background is the color to use for the background

#BackgroundOpacity is the opacity of the background, 0 for transparent, 100 for opaque. Your image must have an alpha channel for this to work.



############################################################

filter Sphere (image in,

int RotateX_Start: -360-360 (90),

int RotateY_Start: -360-360 (90),

#Starting from RotateY_Start =120 you will start with sphere fully invisible then it will start to appear
#When equal or more then 0 sphere will become fully visible

int RotateZ_Start: -360-360 (0),

int Add_RotateX: -360-360(0),

int Add_RotateY: -360-360(0),

int Add_RotateZ: -360-360(0),

int Multiply_X: 1-100(1),

int Multiply_Y: 1-100(1),

int Multiply_Z: 1-100(1),

int Zoom_Start: 1-300 (100),

int Add_Zoom: 1-300 (100),

bool Flip_X,

bool Flip_Y,

int BackgroundOpacity: 0-100 (0),

color background)



rd=min(X,Y)*((Zoom_Start/100)+(t*(Add_Zoom-Zoom_Start)/100));



if r>rd then

rgba:[background[0],background[1],background[2],BackgroundOpacity/100];

else



beta = (pi/180) * RotateX_Start + (pi/180)*(Add_RotateX*Multiply_X*t);

gamma = (pi/180) * RotateY_Start + (pi/180)*(Add_RotateY*Multiply_Y*t);

alpha = (pi/180) * RotateZ_Start + (pi/180)*(Add_RotateZ*Multiply_Z*t);



sa=sin(alpha);

sb=sin(beta);

ca=cos(alpha);

cb=cos(beta);



theta=a;

phi=acos(r/rd);



x0=cos(theta)*cos(phi);

y0=sin(theta)*cos(phi);

z0=sin(phi);

x1=ca*x0+sa*y0;

z1=(-sa*-sb*x0)+(ca*-sb*y0+cb*z0);





if z1 >= 0 || 1 then

y1=cb*-sa*x0+cb*ca*y0+sb*z0;

else

z1=z1-2*cb*z0;

y1=cb*-sa*x0+cb*ca*y0-sb*z0;

end;



theta1=atan(-x1/y1)+(if y1>0 then pi/2 else 3*pi/2 end);

phi1=asin(z1);



ix = ((theta1*1+gamma)%(2*pi)-pi)/pi*X;

iy = -phi1/(pi/2)*Y;



if Flip_X then

ix = -ix

end;



if Flip_Y then

iy= -iy

end;



in(xy:[ix,iy])

end



end

----------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------

EXAMPLES

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------



this with with RotateX at -180° and Add_RotateX to 270° rest as default,about 30 frames

Note that if you reverse the Animation in Combine mode same effect will give quite different result as you can see here





----------------------------------------------------------------------
i was curious to see what in practice would happen with negative values
Of course those negative valors have non sense but that make me even more curious

well what could happen include something as this(layerstack was reverted)

1normal (click for bigger)



2 (click for bigger)

here gamma start t negative value...so a slice at the right seems duplicated



3 and then in pratice it go on adding that slice (that the visual effect, in the frames the area that could not be rendered is just transparent,






-------------------------------------------------------------------------------------------------------------------------------------------------------------------------



http://www.flickr.com/photos/97844002@N00/

PhotoMaster
Member




Profile
Send PM


Joined: May 15, 2006
Posts: 528
posted on: Jul 21, 2007 at 12:41:22 EDITDELETELOCK
I did a quick modify to animate the Kaleidoscope code.
---------------------------------------------------------------------------------------------------
 KALEIDOSCOPE by Nathan Du Gargoyle



#--------------------------------------------------------------------------------------------
# Original KALEIDOSCOPE by Nathan Du Gargoyle
# Modified for animation by PhotoMaster
# Only one line was modified so I can't take any real credit.
#--------------------------------------------------------------------------------------------

filter kaleidoscope (image in, int ng: 2-10, float rot: 0-6.28318, int sx: 0-2000, int sy: 0-2000, float rad: 0-100)
intang=2*pi/ng;na=a+pi/2;
ang=intang/2-na%intang;
ang=(rot*t)+(intang/2-sqrt(ang^2)); # <----------------------I changed this line
xr=r*rad;
rad=rad*min(X,Y);
if xr<rad then
nr=xr;
else
ang=2*ang;
nr=rad*xr/R;
end;
nx=nr*cos(ang);
ny=nr*sin(ang);
nx=(nx+sx)%(W-1)-(X-1);
ny=(ny+sy)%(H-1)-(Y-1);
in(xy:[nx,ny])
end


--------------------------------------------------------------------------------------------------------------------------------------------------------------

Example...



or


or



Greg



My Sigs = My Photos

PhotoComix
Manager




Profile
Send PM


Joined: Jun 13, 2005
Posts: 5328
posted on: Jul 21, 2007 at 05:16:41 EDITDELETELOCK
Nice one...i tried to do something similar with no much success.
just some quick question:
1 which line you changed?
(and there is a way to confront 2 similar codes and automatically spot differences? )

2 the animation is sort of automatic (with the option to chose the number or frame, but no other option) or is in some way customizable?
(i didn't try yet i'm not to my usual laptop)

------------------------------------------------------------------------------------------------------------------------------------
I tried to add animation to the Kaleidoscope in a similar way then Josh Sommers did for sphere but for some reason i always get error message....my idea was to split all controls in 2, a initial setting for the start values, let say for the first frame,
and the others for values to add ...)

But still i get only error message...i still puzzling my mind...nice that you find another solution



http://www.flickr.com/photos/97844002@N00/

PhotoComix
Manager




Profile
Send PM


Joined: Jun 13, 2005
Posts: 5328
posted on: Jul 21, 2007 at 05:25:22 EDITDELETELOCK
PS do you see my sort of eliptical sig?
That is a sphere after i scale down High....i still try to figure how to add something similar as option
(better if the change could be progressive....as progressively scaling W(ide) and H(igh) each with its own paramether and then the reverse.

still i can't figure out how....must be quite simple but ....well till now i get no success



http://www.flickr.com/photos/97844002@N00/

PhotoMaster
Member




Profile
Send PM


Joined: May 15, 2006
Posts: 528
posted on: Jul 21, 2007 at 10:20:48 EDITDELETELOCK
I edited my post to show the line that was changed.

I have been playing with the rotating sphere but can't seem to get the results I'm looking for. I will keep playing with it though.

Greg



My Sigs = My Photos

PhotoComix
Manager




Profile
Send PM


Joined: Jun 13, 2005
Posts: 5328
posted on: Jul 22, 2007 at 10:17:15 EDITDELETELOCK
I tried to contact Mark Probst, the developer of MM hoping he could find the time to answer to some questions

In the time while if Photomaster, as anyone that is trying to write / edit codes want to list some point
(as why this code ,THIS,didn't work, or how to solve THIS......, or some relevant question ) this could be the right moment

About me i believe my main problem is similar to Photomaster...i want add animation feature,(porting the same kind of solution used by Josh Sommers to the Animated Sphere posted here, to other scripts.)

I would love a Animated Droste effect, but for start i would be happy to be successful with much more simple code, but i fail with even the most simple one as "Radial Blur", or with very similar, as the "Sphere with Reflection" and i just can't understand what is wrong.

I'm not too interesting to animate just using a periodic functions,i would like the ability to set a start and a final value for the most relevant variant (and interpolate values for the in between frames)
This was done by Pisco Bandito in the Animated Sphere and is that kind of animation i want add to other MM codes

Of course anybody else that can help is heartily welcome



http://www.flickr.com/photos/97844002@N00/

Gargoyle
Member




Profile
Send PM


Joined: Aug 11, 2006
Posts: 677
posted on: Jul 23, 2007 at 04:24:07 EDITDELETELOCK
Hi guys, Hope you got my messages. Sorry again I haven't been much help recently but I'll be back to normal soon I hope!



PhotoComix
Manager




Profile
Send PM


Joined: Jun 13, 2005
Posts: 5328
posted on: Sep 09, 2007 at 11:25:04 EDITDELETELOCK
i just notice this topic need updates, there are some new codes available
(then one of the author wrote using the old syntax....not sure if i will able to fix for latest MM)



http://www.flickr.com/photos/97844002@N00/

PhotoComix
Manager




Profile
Send PM


Joined: Jun 13, 2005
Posts: 5328
posted on: Nov 22, 2007 at 10:25:51 EDITDELETELOCK
:s:why this topic vanish?
Only google seems able to find it



http://www.flickr.com/photos/97844002@N00/




Quick jump to forum

Post New Topic . Start New Poll . Post reply (quick reply)




Post Reply to Topic (Mathmap 1.20 Codes (only For Mm 1.20))


Clickable smilies




Post Body

More options:
Enable LBCode . Enable Smilies . Show signature . Recieve email notification of replies

Upload Image
All rights reserved www.gimptalk.com (Gimp Tutorials)