1 /* GIMP - The GNU Image Manipulation Program
2  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3  *
4  * IfsCompose is a interface for creating IFS fractals by
5  * direct manipulation.
6  * Copyright (C) 1997 Owen Taylor
7  *
8  * 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
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  */
20 
21 typedef struct {
22   gdouble a11,a12,a21,a22,b1,b2;
23 } Aff2;
24 
25 typedef struct {
26   gdouble vals[3][4];
27 } Aff3;
28 
29 typedef struct {
30   GdkPoint *points;
31   gint      npoints;
32 } IPolygon;
33 
34 typedef struct {
35   gdouble  x, y;
36   gdouble  theta;
37   gdouble  scale;
38   gdouble  asym;
39   gdouble  shear;
40   gint     flip;
41 
42   GimpRGB  red_color;
43   GimpRGB  green_color;
44   GimpRGB  blue_color;
45   GimpRGB  black_color;
46 
47   GimpRGB  target_color;
48   gdouble  hue_scale;
49   gdouble  value_scale;
50 
51   gint     simple_color;
52   gdouble  prob;
53 } AffElementVals;
54 
55 typedef struct
56 {
57   gint num_elements;
58   gint iterations;
59   gint max_memory;
60   gint subdivide;
61   gdouble radius;
62   gdouble aspect_ratio;
63   gdouble center_x;
64   gdouble center_y;
65 } IfsComposeVals;
66 
67 typedef struct {
68   AffElementVals v;
69 
70   Aff2 trans;
71   Aff3 color_trans;
72 
73   gchar *name;
74 
75   IPolygon *click_boundary;
76   IPolygon *draw_boundary;
77 } AffElement;
78 
79 
80 /* manipulation of affine transforms */
81 void aff2_translate       (Aff2    *naff,
82                            gdouble  x,
83                            gdouble  y);
84 void aff2_rotate          (Aff2    *naff,
85                            gdouble  theta);
86 void aff2_scale           (Aff2    *naff,
87                            gdouble  s,
88                            gint     flip);
89 void aff2_distort         (Aff2    *naff,
90                            gdouble  asym,
91                            gdouble  shear);
92 void aff2_compute_stretch (Aff2    *naff,
93 			   gdouble  xo,
94                            gdouble  yo,
95 			   gdouble  xn,
96                            gdouble  yn);
97 void aff2_compute_distort (Aff2    *naff,
98 			   gdouble  xo,
99                            gdouble  yo,
100 			   gdouble  xn,
101                            gdouble  yn);
102 void aff2_compose         (Aff2    *naff,
103                            Aff2    *aff1,
104                            Aff2    *aff2);
105 void aff2_invert          (Aff2    *naff,
106                            Aff2    *aff);
107 void aff2_apply           (Aff2    *aff,
108                            gdouble  x,
109                            gdouble  y,
110 			   gdouble *xf,
111                            gdouble *yf);
112 void aff2_fixed_point     (Aff2    *aff,
113                            gdouble *xf,
114                            gdouble *yf);
115 void aff3_apply           (Aff3    *t,
116                            gdouble  x,
117                            gdouble  y,
118                            gdouble  z,
119 			   gdouble *xf,
120                            gdouble *yf,
121                            gdouble *zf);
122 
123 
124 /* manipulation of polygons */
125 IPolygon *ipolygon_convex_hull (IPolygon *poly);
126 gint      ipolygon_contains    (IPolygon *poly,
127                                 gint      xt,
128                                 gint      yt);
129 
130 
131 /* manipulation of composite transforms */
132 AffElement *aff_element_new                  (gdouble      x,
133                                               gdouble      y,
134                                               GimpRGB     *color,
135                                               gint         count);
136 void        aff_element_free                 (AffElement  *elem);
137 void        aff_element_compute_trans        (AffElement  *elem,
138                                               gdouble      width,
139 					      gdouble      height,
140 					      gdouble      center_x,
141                                               gdouble      center_y);
142 void        aff_element_compute_color_trans  (AffElement  *elem);
143 void        aff_element_decompose_trans      (AffElement  *elem,
144                                               Aff2        *aff,
145 					      gdouble      width,
146                                               gdouble      height,
147 					      gdouble      center_x,
148                                               gdouble      center_y);
149 void        aff_element_compute_boundary     (AffElement  *elem,
150                                               gint         width,
151 					      gint         height,
152 					      AffElement **elements,
153 					      gint         num_elements);
154 void        aff_element_draw                 (AffElement  *elem,
155                                               gint         selected,
156                                               gint         width,
157                                               gint         height,
158                                               cairo_t     *cr,
159                                               GdkColor    *color,
160                                               PangoLayout *layout);
161 
162 
163 void       ifs_render (AffElement     **elements,
164                        gint             num_elements,
165                        gint             width,
166                        gint             height,
167                        gint             nsteps,
168                        IfsComposeVals  *vals,
169                        gint             band_y,
170                        gint             band_height,
171                        guchar          *data,
172                        guchar          *mask,
173                        guchar          *nhits,
174                        gboolean         preview);
175 
176 gchar    * ifsvals_stringify    (IfsComposeVals   *vals,
177                                  AffElement      **elements);
178 gboolean   ifsvals_parse_string (const gchar      *str,
179                                  IfsComposeVals   *vals,
180                                  AffElement     ***elements);
181