ifs-compose.h 5.96 KB
Newer Older
1
/* GIMP - The GNU Image Manipulation Program
Elliot Lee's avatar
Elliot Lee committed
2 3 4 5 6 7 8
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * IfsCompose is a interface for creating IFS fractals by
 * direct manipulation.
 * Copyright (C) 1997 Owen Taylor
 *
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation; either version 3 of the License, or
Elliot Lee's avatar
Elliot Lee committed
10 11 12 13 14 15 16 17
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
Elliot Lee's avatar
Elliot Lee committed
19 20 21 22 23 24 25 26 27 28 29 30
 */

typedef struct {
  gdouble a11,a12,a21,a22,b1,b2;
} Aff2;

typedef struct {
  gdouble vals[3][4];
} Aff3;

typedef struct {
  GdkPoint *points;
31
  gint      npoints;
Elliot Lee's avatar
Elliot Lee committed
32 33 34
} IPolygon;

typedef struct {
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
  gdouble  x, y;
  gdouble  theta;
  gdouble  scale;
  gdouble  asym;
  gdouble  shear;
  gint     flip;

  GimpRGB  red_color;
  GimpRGB  green_color;
  GimpRGB  blue_color;
  GimpRGB  black_color;

  GimpRGB  target_color;
  gdouble  hue_scale;
  gdouble  value_scale;

  gint     simple_color;
  gdouble  prob;
Elliot Lee's avatar
Elliot Lee committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
} AffElementVals;

typedef struct
{
  gint num_elements;
  gint iterations;
  gint max_memory;
  gint subdivide;
  gdouble radius;
  gdouble aspect_ratio;
  gdouble center_x;
  gdouble center_y;
} IfsComposeVals;

typedef struct {
  AffElementVals v;

  Aff2 trans;
  Aff3 color_trans;

  gchar *name;

  IPolygon *click_boundary;
  IPolygon *draw_boundary;
} AffElement;

Sven Neumann's avatar
Sven Neumann committed
79

Elliot Lee's avatar
Elliot Lee committed
80
/* manipulation of affine transforms */
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
void aff2_translate       (Aff2    *naff,
                           gdouble  x,
                           gdouble  y);
void aff2_rotate          (Aff2    *naff,
                           gdouble  theta);
void aff2_scale           (Aff2    *naff,
                           gdouble  s,
                           gint     flip);
void aff2_distort         (Aff2    *naff,
                           gdouble  asym,
                           gdouble  shear);
void aff2_compute_stretch (Aff2    *naff,
			   gdouble  xo,
                           gdouble  yo,
			   gdouble  xn,
                           gdouble  yn);
void aff2_compute_distort (Aff2    *naff,
			   gdouble  xo,
                           gdouble  yo,
			   gdouble  xn,
                           gdouble  yn);
void aff2_compose         (Aff2    *naff,
                           Aff2    *aff1,
                           Aff2    *aff2);
void aff2_invert          (Aff2    *naff,
                           Aff2    *aff);
void aff2_apply           (Aff2    *aff,
                           gdouble  x,
                           gdouble  y,
			   gdouble *xf,
                           gdouble *yf);
void aff2_fixed_point     (Aff2    *aff,
                           gdouble *xf,
                           gdouble *yf);
void aff3_apply           (Aff3    *t,
                           gdouble  x,
                           gdouble  y,
                           gdouble  z,
			   gdouble *xf,
                           gdouble *yf,
                           gdouble *zf);
Sven Neumann's avatar
Sven Neumann committed
122

Elliot Lee's avatar
Elliot Lee committed
123 124

/* manipulation of polygons */
Sven Neumann's avatar
Sven Neumann committed
125
IPolygon *ipolygon_convex_hull (IPolygon *poly);
126 127 128
gint      ipolygon_contains    (IPolygon *poly,
                                gint      xt,
                                gint      yt);
Sven Neumann's avatar
Sven Neumann committed
129

Elliot Lee's avatar
Elliot Lee committed
130 131

/* manipulation of composite transforms */
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
AffElement *aff_element_new                  (gdouble      x,
                                              gdouble      y,
                                              GimpRGB     *color,
                                              gint         count);
void        aff_element_free                 (AffElement  *elem);
void        aff_element_compute_trans        (AffElement  *elem,
                                              gdouble      width,
					      gdouble      height,
					      gdouble      center_x,
                                              gdouble      center_y);
void        aff_element_compute_color_trans  (AffElement  *elem);
void        aff_element_decompose_trans      (AffElement  *elem,
                                              Aff2        *aff,
					      gdouble      width,
                                              gdouble      height,
					      gdouble      center_x,
                                              gdouble      center_y);
void        aff_element_compute_boundary     (AffElement  *elem,
                                              gint         width,
					      gint         height,
					      AffElement **elements,
					      gint         num_elements);
154 155
void        aff_element_draw                 (AffElement  *elem,
                                              gint         selected,
156
                                              gint         width,
157
                                              gint         height,
158 159 160
                                              cairo_t     *cr,
                                              GdkColor    *color,
                                              PangoLayout *layout);
Sven Neumann's avatar
Sven Neumann committed
161 162


163 164 165 166 167 168 169 170 171 172 173 174
void       ifs_render (AffElement     **elements,
                       gint             num_elements,
                       gint             width,
                       gint             height,
                       gint             nsteps,
                       IfsComposeVals  *vals,
                       gint             band_y,
                       gint             band_height,
                       guchar          *data,
                       guchar          *mask,
                       guchar          *nhits,
                       gboolean         preview);
Sven Neumann's avatar
Sven Neumann committed
175

176 177 178 179 180
gchar    * ifsvals_stringify    (IfsComposeVals   *vals,
                                 AffElement      **elements);
gboolean   ifsvals_parse_string (const gchar      *str,
                                 IfsComposeVals   *vals,
                                 AffElement     ***elements);