[Gimp-developer] [patch] for the flame plug-in

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I saw the flame plug-in isn't updated by the orginial author since a long 
time, but he continued his work as seen at http://www.flam3.com . He just did 
not continue work on the gimp plug-in. What I simply did was merging 
code together. I copied the new variations from the flam3 code into the flame 
plug-in, so they can also be used within gimp. I also added some other small 
stuff so the new merged variations can be used.
What still works is saving and loading the files from the plug-in, also the 
old files saved with the older version still can be loaded. Random works too.

Apply the patch to the plug-ins/flame directory in the gimp source tree and 
it'll work.

I hope this can be merged into future versions of gimp, if there are no other 
future plans for the flame plug-in

Thanks!
- Dennis Gnad
diff -Naur flame-orig/README flame/README
--- flame-orig/README	1997-11-24 23:05:16.000000000 +0100
+++ flame/README	2004-12-26 02:46:40.105203040 +0100
@@ -1,12 +1,23 @@
 flame - cosmic recursive fractal flames
+
 Scott Draves <spot@xxxxxxxxxx>
+his email mentioned in the flam3 source <source@xxxxxxxxx>
+ - the original plug-in, and the flam3 code
+
+
+Dennis Gnad <bluedrago@xxxxxx>
+ - just merged new variations from flam3 code into this plug-in
 
 get source code from
 http://www.cs.cmu.edu/~spot/gimp/flame.tar.gz
+ - this file seems not to exist anymore
+ - new link is http://www.flam3.com/flam3-2.1.tar.gz (stable source)
 
 images, documentation, and other interfaces (a batch animation
 renderer and a low-quality interactive editor) are available from
 http://www.cs.cmu.edu/~spot/flame.html
+ - this site seems not to exist anymore
+ - new site is http://www.flam3.com
 
 -----------------------
 
@@ -18,6 +29,11 @@
 
 -----------------------
 
+0.13 as of Sun Dec 26 2004
+the original author didn't continue this plugin, but he continued his work
+on flam3. I merged the new variations from flam3 into this plugin.
+so all credit still should got to Scott Draves
+
 0.12 as of Thu Oct 9
 added variation_same. made preview have same aspect ratio as final
 image.  included binary in tar file.
diff -Naur flame-orig/flame.c flame/flame.c
--- flame-orig/flame.c	2004-11-14 13:40:49.000000000 +0100
+++ flame/flame.c	2004-12-25 23:48:51.142131960 +0100
@@ -44,7 +44,7 @@
 #define SCALE_WIDTH       150
 #define PREVIEW_SIZE      150
 #define EDIT_PREVIEW_SIZE 85
-#define NMUTANTS          9
+#define NMUTANTS          24
 
 #define BLACK_DRAWABLE    (-2)
 #define GRADIENT_DRAWABLE (-3)
@@ -737,6 +737,21 @@
                                       _("Horseshoe"),  4,
                                       _("Polar"),      5,
                                       _("Bent"),       6,
+                                      _("Heart"),       7,
+                                      _("Disc"),       8,
+                                      _("Spiral"),       9,
+                                      _("Hyperbolic"),       10,
+                                      _("Diamond"),       11,
+                                      _("Ex"),       12,
+                                      _("Julia"),       13,
+                                      _("Handkerchief"),       14,
+                                      _("Waves"),       15,
+                                      _("Fisheye"),       16,
+                                      _("Popcorn"),       17,
+                                      _("Exponential"),       18,
+                                      _("Power"),       19,
+                                      _("Cosine"),       20,
+                                      _("Sawtooth"),       21,
                                       NULL);
 
       gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo),
diff -Naur flame-orig/libifs.c flame/libifs.c
--- flame-orig/libifs.c	2003-11-26 20:20:16.000000000 +0100
+++ flame/libifs.c	2004-12-26 02:35:56.083109280 +0100
@@ -26,7 +26,7 @@
 
 #include "libifs.h"
 
-#define CHOOSE_XFORM_GRAIN 100
+#define CHOOSE_XFORM_GRAIN 10000
 
 
 /*
@@ -91,6 +91,7 @@
       ty = coef[0][1] * p[0] + coef[1][1] * p[1] + coef[2][1];
 
       p[0] = p[1] = 0.0;
+      
       /* then add in proportional amounts of each of the variations */
       v = vari[0];
       if (v > 0.0) {
@@ -114,7 +115,7 @@
       
       v = vari[2];
       if (v > 0.0) {
-	 /* complex */
+	 /* spherical */
 	 double nx, ny;
 	 double r2 = tx * tx + ty * ty + 1e-6;
 	 nx = tx / r2;
@@ -154,6 +155,7 @@
 
       v = vari[5];
       if (v > 0.0) {
+      /* polar */
 	 double nx, ny;
 	 if (tx < -EPS || tx > EPS ||
 	     ty < -EPS || ty > EPS)
@@ -178,6 +180,229 @@
 	 p[1] += v * ny;
       }
 
+      /* new merged code follows, changed the "v != 0.0" to "v > 0.0" */
+      
+      v = vari[7];
+      if (v > 0.0) {
+	/* heart */
+	 double a, r2;
+	 if (tx < -EPS || tx > EPS ||
+	     ty < -EPS || ty > EPS)
+	    a = atan2(tx, ty);
+	 else
+	    a = 0.0;
+	 r2 = sqrt(tx*tx + ty*ty);
+	 a *= r2;
+	 p[0] += v * sin(a) * r2;
+	 p[1] += v * cos(a) * -r2;
+      }
+
+      v = vari[8];
+      if (v > 0.0) {
+	/* disc */
+	 double a, r2;
+	 double nx, ny;
+	 nx = tx * M_PI;
+	 ny = ty * M_PI;
+	 if (tx < -EPS || tx > EPS ||
+	     ty < -EPS || ty > EPS)
+	    a = atan2(nx, ny);
+	 else
+	    a = 0.0;
+	 r2 = sqrt(nx*nx + ny*ny);
+	 p[0] += v * sin(r2) * a / M_PI;
+	 p[1] += v * cos(r2) * a / M_PI;
+      }
+
+      v = vari[9];
+      if (v > 0.0) {
+	/* spiral */
+	 double a, r2;
+	 if (tx < -EPS || tx > EPS ||
+	     ty < -EPS || ty > EPS)
+	    a = atan2(tx, ty);
+	 else
+	    a = 0.0;
+	 r2 = sqrt(tx*tx + ty*ty) + 1e-6;
+	 p[0] += v * (cos(a) + sin(r2)) / r2;
+	 p[1] += v * (sin(a) - cos(r2)) / r2;
+      }
+
+      v = vari[10];
+      if (v > 0.0) {
+	/* hyperbolic */
+	 double a, r2;
+	 if (tx < -EPS || tx > EPS ||
+	     ty < -EPS || ty > EPS)
+	    a = atan2(tx, ty);
+	 else
+	    a = 0.0;
+	 r2 = sqrt(tx*tx + ty*ty) + 1e-6;
+	 p[0] += v * sin(a) / r2;
+	 p[1] += v * cos(a) * r2;
+      }
+
+      v = vari[11];
+      if (v > 0.0) {
+	/* diamond */
+	 double a, r2;
+	 if (tx < -EPS || tx > EPS ||
+	     ty < -EPS || ty > EPS)
+	    a = atan2(tx, ty);
+	 else
+	    a = 0.0;
+	 r2 = sqrt(tx*tx + ty*ty);
+	 p[0] += v * sin(a) * cos(r2);
+	 p[1] += v * cos(a) * sin(r2);
+      }
+
+      v = vari[12];
+      if (v > 0.0) {
+	/* ex */
+	 double a, r2;
+	 double n0, n1, m0, m1;
+	 if (tx < -EPS || tx > EPS ||
+	     ty < -EPS || ty > EPS)
+	    a = atan2(tx, ty);
+	 else
+	    a = 0.0;
+	 r2 = sqrt(tx*tx + ty*ty);
+	 n0 = sin(a+r2);
+	 n1 = cos(a-r2);
+	 m0 = n0 * n0 * n0 * r2;
+	 m1 = n1 * n1 * n1 * r2;
+	 p[0] += v * (m0 + m1);
+	 p[1] += v * (m0 - m1);
+      }
+
+      v = vari[13];
+      if (v > 0.0) {
+	 double a, r2, nx, ny;
+	 /* julia */
+	 if (tx < -EPS || tx > EPS ||
+	     ty < -EPS || ty > EPS)
+	    a = atan2(tx, ty)/2.0;
+	 else
+	    a = 0.0;
+	 if (flam3_random_bit()) a += M_PI;
+	 r2 = pow(tx*tx + ty*ty, 0.25);
+	 nx = r2 * cos(a);
+	 ny = r2 * sin(a);
+	 p[0] += v * nx;
+	 p[1] += v * ny;
+      }
+
+      v = vari[14];
+      if (v > 0.0) {
+	/* folded handkerchief */
+	/* bent would be here normally in flam3 */
+	 double a, r2;
+	 if (tx < -EPS || tx > EPS ||
+	     ty < -EPS || ty > EPS)
+	    a = atan2(tx, ty);
+	 else
+	    a = 0.0;
+	 r2 = sqrt(tx*tx + ty*ty);
+	 p[0] += v * sin(a+r) * r2;
+	 p[1] += v * cos(a-r) * r2;
+      }
+
+      v = vari[15];
+      if (v > 0.0) {
+	 double nx, ny;
+	 double dx, dy;
+	 /* waves */
+	 dx = coef[2][0];
+	 dy = coef[2][1];
+	 nx = tx + coef[1][0]*sin(ty/((dx*dx)+EPS));
+	 ny = ty + coef[1][1]*sin(tx/((dy*dy)+EPS));
+	 p[0] += v * nx;
+	 p[1] += v * ny;
+      }
+
+      v = vari[16];
+      if (v > 0.0) {
+	 double nx, ny;
+	 double a, r2;
+	 /* fisheye */
+	 r2 = sqrt(tx*tx + ty*ty);
+	 a = atan2(tx, ty);
+	 r2 = 2 * r2 / (r2 + 1);
+	 nx = r2 * cos(a);
+	 ny = r2 * sin(a);
+	 p[0] += v * nx;
+	 p[1] += v * ny;
+      }
+
+      v = vari[17];
+      if (v > 0.0) {
+	 double nx, ny;
+	 double dx, dy;
+	 /* popcorn */
+	 dx = tan(3*ty);
+	 if (dx != dx) dx = 0.0;
+	 dy = tan(3*tx);
+	 if (dy != dy) dy = 0.0;
+	 nx = tx + coef[2][0] * sin(dx);
+	 ny = ty + coef[2][1] * sin(dy);
+	 p[0] += v * nx;
+	 p[1] += v * ny;
+      }
+
+      v = vari[18];
+      if (v > 0.0) {
+	 double nx, ny;
+	 double dx, dy;
+	 /* exponential */
+	 dx = exp(tx) / 2.718281828459045;
+	 dy = M_PI * ty;
+	 nx = cos(dy) * dx;
+	 ny = sin(dy) * dx;
+	 p[0] += v * nx;
+	 p[1] += v * ny;
+      }
+
+      v = vari[19];
+      if (v > 0.0) {
+	 double nx, ny;
+	 /* power */
+	 double a, r2, sa;
+	 r2 = sqrt(tx*tx + ty*ty);
+	 a = atan2(tx, ty);
+	 sa = sin(a);
+	 r2 = pow(r2, sa);
+	 nx = r2 * cos(a);
+	 ny = r2 * sa;
+	 p[0] += v * nx;
+	 p[1] += v * ny;
+      }
+
+      v = vari[20];
+      if (v > 0.0) {
+	  double nx, ny;
+	  /* cosine */
+	  nx = cos(tx * M_PI) * cosh(ty);
+	  ny = -sin(tx * M_PI) * sinh(ty);
+	  p[0] += v * nx;
+	  p[1] += v * ny;
+      }
+
+      v = vari[21];
+      if (v > 0.0) {
+	  double nx, ny;
+	  double a, r2;
+	  /* sawtooth */
+	  r2 = sqrt(tx*tx + ty*ty);
+	  r2 = fmod(r2 + 1.0, 2.0) - 1.0;
+	  a = atan2(tx, ty);
+	  nx = cos(a) * r2;
+	  ny = sin(a) * r2;
+	  p[0] += v * nx;
+	  p[1] += v * ny;
+      }
+
+
+
       /* if fuse over, store it */
       if (i >= 0) {
 	 points[i][0] = p[0];
@@ -186,12 +411,25 @@
       }
    }
 #if 0
-   if ((count_large > 10 || count_nan > 10)
+   if ((count_large > 25 || count_nan > 25)
        && !getenv("PVM_ARCH"))
       fprintf(stderr, "large = %d nan = %d\n", count_large, count_nan);
 #endif
 }
 
+int flam3_random_bit() {
+  int n = 0;
+  int l;
+  if (0 == n) {
+    l = random();
+    n = 20;
+  } else {
+    l = l >> 1;
+    n--;
+  }
+  return l & 1;
+}
+
 /* args must be non-overlapping */
 void mult_matrix(s1, s2, d)
    double s1[2][2];
@@ -922,7 +1160,9 @@
       2, 2, 2,
       3, 3, 3,
       4, 4,
-      5};
+      5,
+      6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
+      };
    static int var_distrib[] = {
       -1, -1, -1,
       0, 0, 0, 0,
@@ -930,7 +1170,9 @@
       2, 2, 2,
       3, 3,
       4, 4,
-      5};
+      5,
+      6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
+      };
 
    static int mixed_var_distrib[] = {
       0, 0, 0,
@@ -938,7 +1180,9 @@
       2, 2, 2,
       3, 3,
       4, 4,
-      5, 5};
+      5, 5,
+      6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
+      };
 
    get_cmap(cmap_random, cp->cmap, 256);
    cp->time = 0.0;
diff -Naur flame-orig/libifs.h flame/libifs.h
--- flame-orig/libifs.h	1998-04-13 07:42:01.000000000 +0200
+++ flame/libifs.h	2004-12-26 01:38:26.252563240 +0100
@@ -31,8 +31,8 @@
 
 #define variation_random (-1)
 
-#define NVARS   7
-#define NXFORMS 6
+#define NVARS   22
+#define NXFORMS 12
 
 typedef double point[3];
 

[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux