home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 November / Chip_2001-11_cd1.bin / sharewar / chaospro / cpro302.exe / FRACTINT.CCL < prev    next >
Encoding:
Text File  |  2001-06-24  |  11.0 KB  |  517 lines

  1. comment {
  2. These formulas should imitate FractInt's coloring
  3. options for the formula fractal type.
  4. If you encounter problems, please let me know.
  5. Not all FractInt options work.
  6.  
  7. Enjoy,
  8.   Martin Pfingstl
  9. }
  10.  
  11. Inside {
  12. real z_min,zmodulo;
  13. int iEpsilonCross;
  14. int min_iter,current_iter;
  15. parameter int iInside;
  16. parameter int iColorIndex;
  17. parameter bool bTruncate;
  18. parameter real iEpsCrossDistance;
  19.  
  20.     void init(void)
  21.     {
  22.         if (iInside==1 || iInside==2)
  23.         {
  24.             z_min=1000000;
  25.         }
  26.         if (iInside==2)
  27.         {        
  28.             current_iter=1;
  29.             min_iter=1;
  30.         }
  31.         if (iInside==4)
  32.         {
  33.             iEpsilonCross=0; // 0 means, nothing has been done...
  34.         }
  35.     }
  36.     void loop(void)
  37.     {
  38.         if (iInside==1) // bof60
  39.         {
  40.             zmodulo=|z|;
  41.             if (zmodulo<z_min)
  42.             {
  43.                 z_min=zmodulo;
  44.             }
  45.         }
  46.         else if (iInside==2) // bof61
  47.         {
  48.             current_iter=current_iter+1;
  49.             zmodulo=|z|;
  50.             if (zmodulo<z_min)
  51.             {
  52.                 z_min=zmodulo;
  53.                 min_iter=current_iter;
  54.             }
  55.         }
  56.         else if (iInside==4) // epsilon cross
  57.         {
  58.             if (iEpsilonCross==0)
  59.             {
  60.                 if (abs(real(z))<iEpsCrossDistance)
  61.                 {
  62.                     iEpsilonCross=2;
  63.                 }
  64.                 if (abs(imag(z))<iEpsCrossDistance)
  65.                 {
  66.                     iEpsilonCross=4;
  67.                 }
  68.             }
  69.  
  70.             current_iter=current_iter+1;
  71.             zmodulo=|z|;
  72.             if (zmodulo<z_min)
  73.             {
  74.                 z_min=zmodulo;
  75.                 min_iter=current_iter;
  76.             }
  77.         }
  78.     }
  79.     void final(void)
  80.     {
  81.         alpha=0;
  82.         if (iInside==0)
  83.         {
  84.             if (iColorIndex==-1)
  85.             {
  86.                 index=maxiter;
  87.             }
  88.             else
  89.             {
  90.                 index=iColorIndex;
  91.             }
  92.         }
  93.         else if (iInside==1) // bof60
  94.         {
  95.             index = sqrt(z_min) * 75;
  96.         }
  97.         else if (iInside==2) // bof61
  98.         {
  99.             index=min_iter;
  100.         }
  101.         else if (iInside==3) // zmag
  102.         {
  103.             index = |z| * trunc(maxiter / 2) + 1;
  104.         }
  105.         else if (iInside==4) // Epsilon cross
  106.         {
  107.             index = iEpsilonCross;
  108.         }
  109.         if (bTruncate)
  110.         {
  111.             index=trunc(index);
  112.         }
  113.         alpha=0;
  114.         index=(index%256)/256;
  115.     }
  116.     void description(void)
  117.     {
  118.         this.title="Inside";
  119.         this.helpfile="http://www.chaospro.de/";
  120.     
  121.         iInside.caption="Inside Coloring";
  122.         iInside.hint="This option specifies the algorithm to use for inside coloring";
  123.         iInside.enum="<nnn>\nbof60\nbof61\nzmag\nepscross";
  124.         iInside.default=0;
  125.         
  126.         iColorIndex.caption="Color Index";
  127.         iColorIndex.hint="Specifies the color to use. -1 means 'maxiter'. Parameter is used only if Inside-Coloring is set to <nnn>";
  128.         iColorIndex.default=1.0;
  129.         iColorIndex.min=-1.0;
  130.         iColorIndex.max=255.0;
  131.         
  132.         bTruncate.caption="Truncate";
  133.         bTruncate.hint="If set, the resulting color index gets truncated to the nearest color index. Otherwise (i.e. normal behaviour of ChaosPro) the two neighboured colors would be interpolated.";
  134.         bTruncate.default=true;                          
  135.         
  136.         iEpsCrossDistance.caption="Distance";
  137.         iEpsCrossDistance.hint="Valid only for epsilon cross coloring: Specifies the distance from the axis";
  138.         iEpsCrossDistance.default=0.01;
  139.         iEpsCrossDistance.min=0.0000000000000000001;
  140.         iEpsCrossDistance.max=100000;
  141.     }
  142. }
  143.  
  144. Decomp(OUTSIDE) {
  145. real lowestIter,range;
  146. real z_angle;
  147. parameter int iDecomp;
  148. parameter int iLogmapSetting;
  149. parameter bool bTruncate;
  150.  
  151.     void final(void)
  152.     {
  153.         z_angle = atan2(z);
  154.   
  155.         if (z_angle<0)
  156.         {
  157.             z_angle = z_angle + 2*pi;
  158.         }
  159.  
  160.         if  (iDecomp<256)
  161.         {
  162.             index = 1;
  163.         }
  164.         else
  165.         {
  166.             index = 0;
  167.         }
  168.  
  169.         if  (bTruncate)
  170.         {
  171.             index = index + (z_angle * (iDecomp - index)) / (2 * pi);
  172.         }
  173.         else
  174.         {
  175.  
  176.             index = index + trunc((z_angle * iDecomp) / (2 * pi));
  177.         }
  178.  
  179.         if  (iLogmapSetting != 0 && index > maxiter)
  180.         {
  181.             index = maxiter;
  182.         }    
  183.  
  184.         if  (iLogmapSetting>0)
  185.         {
  186.             // iLogmapSetting=1 ==> Standard logmap, >1 ==> Standard logmap, but starting at iteration count <iLogmapSetting>
  187.             if  (iLogmapSetting>1)
  188.             {
  189.                 lowestIter = iLogmapSetting;
  190.             }
  191.             else
  192.             {
  193.                 lowestIter = 0;
  194.             }
  195.             // Lets initialize a helper variable for the available range (from lowestIter upto maxiter)
  196.             // In order to avoid math errors, let us restrict lowestIter to a value smaller than maxiter...
  197.             if  (lowestIter>=maxiter)
  198.             {
  199.                 lowestIter = maxiter-1;
  200.             }
  201.             if  (lowestIter>0)
  202.             {
  203.                 range = 255 / log(maxiter - lowestIter);
  204.             }
  205.             else
  206.             {
  207.                 range = 256 / log(maxiter);
  208.             }
  209.             if  (index<=lowestIter)
  210.             {
  211.                 index = 1;
  212.             }
  213.             else if  ( (index - lowestIter) / log(index - lowestIter) <= range)
  214.             {
  215.                 if  (lowestIter>0)
  216.                 {
  217.                     index = index - lowestIter + 1;
  218.                 }
  219.                 else
  220.                 {
  221.                     index = index - lowestIter;
  222.                 }
  223.             }
  224.             else
  225.             {
  226.                 index = 1 + range * log(index - lowestIter);
  227.             }
  228.         }
  229.         else if  (iLogmapSetting == -1)
  230.         {
  231.             if (index==0)
  232.             {
  233.                 index = 1;
  234.             }
  235.             else
  236.             {
  237.                 index = 1 + (256 / log(150)) * log(index);
  238.             }
  239.         }
  240.         else if  (iLogmapSetting < -1)
  241.         {
  242.             lowestIter = -iLogmapSetting;
  243.             if  (lowestIter >= maxiter)
  244.             {
  245.                 lowestIter = maxiter - 1;
  246.             }
  247.             range = 256 / sqrt(maxiter - lowestIter);
  248.             if  (index <= lowestIter)
  249.             {
  250.                 index = 1;
  251.             }
  252.             else if  ((index - lowestIter) <= sqr(range))
  253.             {
  254.                 index = index - lowestIter + 1;
  255.             }
  256.             else
  257.             {
  258.                 index = 1 + range * sqrt(index - lowestIter);
  259.             }    
  260.         }
  261.  
  262.         index = (index % 252) / 252;
  263.  
  264.     }
  265.     void description(void)
  266.     {
  267.         this.title = "Decomposition";
  268.         this.helpfile="http://www.chaospro.de/";
  269.  
  270.         iDecomp.caption = "Decomposition";
  271.         iDecomp.hint = "This is the Decomp Option parameter in Fractint.";
  272.         iDecomp.default = 256;
  273.         iDecomp.min = 0;
  274.         iDecomp.max = 256;
  275.  
  276.         iLogmapSetting.caption = "Log Palette";
  277.         iLogmapSetting.hint = "Imitates the Log Palette value in Fractint. 0=no, 1=yes, -1=old, +n=cmprsd, -n=sqrt.";
  278.         iLogmapSetting.default = 0;
  279.  
  280.         bTruncate.caption="Truncate";
  281.         bTruncate.hint="If set, the resulting color index gets truncated to the nearest color index. Otherwise (i.e. normal behaviour of ChaosPro) the two neighboured colors would be interpolated.";
  282.         bTruncate.default=true;                          
  283.   
  284.     }
  285. }
  286.  
  287. Outside(OUTSIDE) {
  288. bool bSkip;
  289. real lowestIter,range;
  290. parameter int iOutside;
  291. parameter real iColorIndex;
  292. parameter bool bTruncate;
  293. parameter bool bRestrict;
  294. parameter int iLogmapSetting;
  295. parameter real rBiomorphSetting;
  296. parameter real rBailoutValue;
  297.  
  298.     void final(void)
  299.     {
  300.         bSkip= (iOutside==1);
  301.         
  302.         index=1+numiter;
  303.         // iOutside: 0 ==> <nnn>
  304.         //           1 ==> iter^
  305.         //           2 ==> real
  306.         //                     3 ==> imag
  307.         //           4 ==> mult
  308.         //           5 ==> mult
  309.         //           6 ==> summ
  310.         //           7 ==> atan
  311.         if (iOutside==2)
  312.         {
  313.             if (bTruncate)
  314.             {
  315.                 index=index+7+trunc(real(z));
  316.             }
  317.             else
  318.             {
  319.                 index=index+7+real(z);
  320.             }
  321.         }
  322.         else if (iOutside==3)
  323.         {
  324.             if (bTruncate)
  325.             {
  326.                 index=index+7+trunc(imag(z));
  327.             }
  328.             else
  329.             {
  330.                 index=index+7+imag(z);
  331.             }
  332.         }
  333.         else if (iOutside==4)
  334.         {
  335.             if (bTruncate)
  336.             {
  337.                 index=trunc(index*real(z)*imag(z));
  338.             }
  339.             else
  340.             {
  341.                 index=index*real(z)*imag(z);
  342.             }
  343.         }
  344.         else if (iOutside==5)
  345.         {
  346.             if (bTruncate)
  347.             {
  348.                 index=index+trunc(real(z)+imag(z));
  349.             }
  350.             else
  351.             {
  352.                 index=index+real(z)+imag(z);
  353.             }
  354.         }
  355.         else if (iOutside==6)
  356.         {
  357.             if (bTruncate)
  358.             {
  359.                 index=trunc(abs(atan2(z)*180/pi));
  360.             }
  361.             else
  362.             {
  363.                 index=abs(atan2(z)*180/pi);
  364.             }
  365.         }
  366.  
  367.         if  (rBiomorphSetting>=0 && ( abs(real(z))<=sqrt(rBailoutValue) || abs(imag(z))<=sqrt(rBailoutValue) ) )
  368.         {
  369.             index = rBiomorphSetting;
  370.             bSkip = false;
  371.         }
  372.  
  373.         if (bRestrict)
  374.         {
  375.             if  (index<0 || index>maxiter)
  376.             {
  377.                 index = 0;
  378.             }
  379.         }
  380.  
  381.         if (iOutside==0)
  382.         {
  383.             index=iColorIndex;
  384.         }
  385.         else
  386.         {
  387.             if  (iLogmapSetting>0)
  388.             {
  389.                 // iLogmapSetting=1 ==> Standard logmap, >1 ==> Standard logmap, but starting at iteration count <iLogmapSetting>
  390.                 if  (iLogmapSetting>1)
  391.                 {
  392.                     lowestIter = iLogmapSetting;
  393.                 }
  394.                 else
  395.                 {
  396.                     lowestIter = 0;
  397.                 }
  398.                 // Lets initialize a helper variable for the available range (from lowestIter upto maxiter)
  399.                 // In order to avoid math errors, let us restrict lowestIter to a value smaller than maxiter...
  400.                 if  (lowestIter>=maxiter)
  401.                 {
  402.                     lowestIter = maxiter-1;
  403.                 }
  404.                 if  (lowestIter>0)
  405.                 {
  406.                     range = 255 / log(maxiter - lowestIter);
  407.                 }
  408.                 else
  409.                 {
  410.                     range = 256 / log(maxiter);
  411.                 }
  412.                 if  (index<=lowestIter)
  413.                 {
  414.                     index = 1;
  415.                 }
  416.                 else if  ( (index - lowestIter) / log(index - lowestIter) <= range)
  417.                 {
  418.                     if  (lowestIter>0)
  419.                     {
  420.                         index = index - lowestIter + 1;
  421.                     }
  422.                     else
  423.                     {
  424.                         index = index - lowestIter;
  425.                     }
  426.                 }
  427.                 else
  428.                 {
  429.                     index = 1 + range * log(index - lowestIter);
  430.                 }
  431.             }
  432.             else if  (iLogmapSetting == -1)
  433.             {
  434.                 if (index==0)
  435.                 {
  436.                     index = 1;
  437.                 }
  438.                 else
  439.                 {
  440.                     index = 1 + (256 / log(150)) * log(index);
  441.                 }
  442.             }
  443.             else if  (iLogmapSetting < -1)
  444.             {
  445.                 lowestIter = -iLogmapSetting;
  446.                 if  (lowestIter >= maxiter)
  447.                 {
  448.                     lowestIter = maxiter - 1;
  449.                 }
  450.                 range = 256 / sqrt(maxiter - lowestIter);
  451.                 if  (index <= lowestIter)
  452.                 {
  453.                     index = 1;
  454.                 }
  455.                 else if  ((index - lowestIter) <= sqr(range))
  456.                 {
  457.                     index = index - lowestIter + 1;
  458.                 }
  459.                 else
  460.                 {
  461.                     index = 1 + range * sqrt(index - lowestIter);
  462.                 }    
  463.             }
  464.         }
  465.  
  466.         if  (bSkip)
  467.         {
  468.             index = (1 + (index - 1)%252) / 252;
  469.         }
  470.         else
  471.         {
  472.             index = (index % 252) / 252;
  473.         }
  474.     }
  475.     void description(void)
  476.     {
  477.         this.title="Outside";
  478.         this.helpfile="http://www.chaospro.de/";
  479.  
  480.         iOutside.caption="Outside Coloring";
  481.         iOutside.hint="This option specifies the algorithm to use for outside coloring";
  482.         iOutside.enum="<nnn>\niter\nreal\nimag\nmult\nsumm\natan";
  483.         iOutside.default=1;
  484.  
  485.         iColorIndex.caption="Color Index";
  486.         iColorIndex.hint="Specifies the color to use. Parameter is used only if Outside-Coloring is set to <nnn>";
  487.         iColorIndex.default=1;
  488.         iColorIndex.min=0;
  489.         iColorIndex.max=255;
  490.  
  491.         bTruncate.caption="Truncate";
  492.         bTruncate.hint="If set, the resulting color index gets truncated to the nearest color index. Otherwise (i.e. normal behaviour of ChaosPro) the two neighboured colors would be interpolated.";
  493.         bTruncate.default=true;                          
  494.  
  495.         bRestrict.caption="Cut Colors";
  496.         bRestrict.hint="If set, the resulting index value is restricted to 0..maxiter: If it falls outside, it is set to 0 or maxiter.";
  497.         bRestrict.default=true;
  498.  
  499.         iLogmapSetting.caption = "Log Palette";
  500.         iLogmapSetting.hint = "Imitates the Log Palette value in Fractint. 0=no, 1=yes, -1=old, +n=cmprsd, -n=sqrt.";
  501.         iLogmapSetting.default = 0;
  502.  
  503.         rBiomorphSetting.caption = "Biomorph Color";
  504.         rBiomorphSetting.hint = "Reconstructs the biomorph option from FractInt. -1 turns biomorph coloring off (default). A color value (0..255) turns it on using the specified color.";
  505.         rBiomorphSetting.default = -1;
  506.         rBiomorphSetting.min = -1;
  507.         rBiomorphSetting.max = 255;
  508.  
  509.         rBailoutValue.caption = "Biomorph Bailout";
  510.         rBailoutValue.hint = "Lets you specify the bailout value used with the biomorph option. Should be set to match to standard bailout value, but may be changed for some reason...";
  511.         rBailoutValue.default = 100.0;
  512.         rBailoutValue.min = 1;
  513.     }
  514. }
  515.  
  516.  
  517.