/[antiright]/antiright/src/afract/afract.c
ViewVC logotype

Diff of /antiright/src/afract/afract.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by jefbed, Tue Jul 26 01:05:51 2005 UTC revision 1.5 by jefbed, Sun Jul 31 16:33:34 2005 UTC
# Line 2  Line 2 
2    AntiRight    AntiRight
3    (c) 2003-2005 Jeffrey Bedard    (c) 2003-2005 Jeffrey Bedard
4    antiright@gmail.com    antiright@gmail.com
5      
6    This file is part of AntiRight.    This file is part of AntiRight.
7      
8    AntiRight is free software; you can redistribute it and/or modify    AntiRight is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.    (at your option) any later version.
12      
13    AntiRight is distributed in the hope that it will be useful,    AntiRight is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.    GNU General Public License for more details.
17      
18    You should have received a copy of the GNU General Public License    You should have received a copy of the GNU General Public License
19    along with AntiRight; if not, write to the Free Software    along with AntiRight; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301  USA    02110-1301  USA
22  */  */
23    
# Line 26  Line 26 
26    
27  unsigned int iterations;  unsigned int iterations;
28  unsigned int threshhold;  unsigned int threshhold;
29    unsigned int scale=25;
30    float resolution=.04;
31  Widget i_field;  Widget i_field;
32  Widget Q_field;  Widget Q_field;
33  Widget P_field;  Widget P_field;
34  Widget t_field;  Widget t_field;
35    Widget scale_field;
36    Widget resolution_field;
37  float Q=0;  float Q=0;
38  float P=0;  float P=0;
39  Pixmap buffer;  Pixmap buffer;
# Line 52  update_fields() Line 56  update_fields()
56    update_field(&t_field, threshhold);    update_field(&t_field, threshhold);
57    update_field(&Q_field, Q);    update_field(&Q_field, Q);
58    update_field(&P_field, P);    update_field(&P_field, P);
59      update_field(&scale_field, scale);
60      update_field(&resolution_field, resolution);
61  }  }
62    
63    
# Line 70  fractal() Line 76  fractal()
76  {  {
77    float x, y;    float x, y;
78    unsigned int point;    unsigned int point;
   unsigned int scale=25;  
79    antiright_draw_foreground(&antiright.graph.drawing, 0, 0, 0);    antiright_draw_foreground(&antiright.graph.drawing, 0, 0, 0);
     
   printf("i:%d, t:%d, q:%f, p:%f\n", iterations, threshhold, Q, P);  
   fflush(stdout);  
80    
81    for(x=-32; x<32; x+=.04)    for(x=-32; x<32; x+=resolution)
82      {      {
83        for(y=-32; y<32; y+=.04)        for(y=-32; y<32; y+=resolution)
84          {          {
85            point=test(x, y);            point=test(x, y);
86            if(point>threshhold)            if(point>threshhold)
# Line 90  fractal() Line 92  fractal()
92          }          }
93      }      }
94  }  }
95    void
96    resolution_mvcb(Widget widget,
97                    XtPointer client_data, XtPointer call_data)
98    {
99      char *input=XmTextFieldGetString(widget);
100      resolution=atof(input);
101      XtFree(input);
102      client_data=NULL;
103      call_data=NULL;
104    }
105  void  void
106  q_mvcb(Widget widget, XtPointer client_data, XtPointer call_data)  q_mvcb(Widget widget, XtPointer client_data, XtPointer call_data)
107  {  {
# Line 119  i_mvcb(Widget widget, XtPointer client_d Line 130  i_mvcb(Widget widget, XtPointer client_d
130    call_data=NULL;    call_data=NULL;
131  }  }
132  void  void
133    scale_mvcb(Widget widget, XtPointer client_data, XtPointer call_data)
134    {
135      char *input=XmTextFieldGetString(widget);
136      scale=atoi(input);
137      XtFree(input);
138      client_data=NULL;
139      call_data=NULL;
140    }
141    
142    void
143  t_mvcb(Widget widget, XtPointer client_data, XtPointer call_data)  t_mvcb(Widget widget, XtPointer client_data, XtPointer call_data)
144  {  {
145    char *input=XmTextFieldGetString(widget);    char *input=XmTextFieldGetString(widget);
# Line 128  t_mvcb(Widget widget, XtPointer client_d Line 149  t_mvcb(Widget widget, XtPointer client_d
149    call_data=NULL;    call_data=NULL;
150  }  }
151    
152  void  void
153  expose_cb()  expose_cb()
154  {  {
155    update_fields();    update_fields();
# Line 138  expose_cb() Line 159  expose_cb()
159                   antiright.graph.height);                   antiright.graph.height);
160    antiright_draw_foreground(&buffer_drawing, 200, 200, 200);    antiright_draw_foreground(&buffer_drawing, 200, 200, 200);
161    fractal();    fractal();
162    XCopyArea(antiright.display, buffer,    XCopyArea(antiright.display, buffer,
163              antiright.graph.drawing.window,              antiright.graph.drawing.window,
164              antiright.graph.drawing.gc, 0, 0, 256,256, 0, 0);              antiright.graph.drawing.gc, 0, 0, 384,384, 0, 0);
165    XFlush(antiright.display);    XFlush(antiright.display);
166    
167    //sleep(1);    //sleep(1);
# Line 161  main(int argc, char **argv) Line 182  main(int argc, char **argv)
182    Widget form;    Widget form;
183    Widget iterate;    Widget iterate;
184    Widget refresh;    Widget refresh;
185      
     
186    iterations=1;    iterations=1;
187    threshhold=1;    threshhold=1;
188    
189    antiright_initialize_application(&argc, argv, "AFract");    antiright_initialize_application(&argc, argv, "AFract");
190    antiright_set_pixmap_from_data(antiright.parent_widget,    antiright_set_pixmap_from_data(antiright.parent_widget,
191                                   antiright_xpm);                                   antiright_xpm);
192    
193    ARCLARG;    ARCLARG;
194    form=antiright_form(antiright.parent_widget);    form=antiright_form(antiright.parent_widget);
     
195    ARCLARG;    ARCLARG;
196    XtVaSetValues(antiright.parent_widget,    XtVaSetValues(antiright.parent_widget,
197                  XmNwidth, 256,                  XmNwidth, 384,
198                  XmNheight, 256,                  XmNheight, 384,
199                  NULL);                  NULL);
200    antiright.graph.width=256;    antiright.graph.width=384;
201    antiright.graph.height=256;    antiright.graph.height=384;
202    XtRealizeWidget(antiright.parent_widget);    XtRealizeWidget(antiright.parent_widget);
203    antiright_form_positions(0, 80, 0, 80);    antiright_form_positions(0, 80, 0, 80);
204    antiright_create_graph(form);    antiright_create_graph(form);
205    XtRemoveAllCallbacks(antiright.graph.widget,    XtRemoveAllCallbacks(antiright.graph.widget,
206                         XmNexposeCallback);                         XmNexposeCallback);
207      XtAddCallback(antiright.graph.widget,
208                    XmNexposeCallback,expose_cb, NULL);
209    
210    ARCLARG;    ARCLARG;
211    antiright_form_positions(80, 90, 0, 100);    antiright_form_positions(80, 90, 0, 25);
212      antiright_label(form, "Scale:");
213      ARCLARG;
214      antiright_form_positions(80, 90, 25, 50);
215      scale_field=XmCreateTextField(form, "Scale",
216                                    antiright.arguments,
217                                    antiright.arguments_int);
218      XtAddCallback(scale_field, XmNactivateCallback, scale_mvcb, NULL);
219      XtManageChild(scale_field);
220      ARCLARG;
221      antiright_form_positions(80, 90, 50, 75);
222      antiright_label(form, "Res.:");
223      ARCLARG;
224      antiright_form_positions(80, 90, 75, 100);
225      resolution_field=XmCreateTextField(form, "Resolution",
226                                         antiright.arguments,
227                                         antiright.arguments_int);
228      XtAddCallback(resolution_field, XmNactivateCallback,
229                    resolution_mvcb, NULL);
230      XtManageChild(resolution_field);
231      ARCLARG;
232      antiright_form_positions(90, 100, 0, 50);
233    iterate=antiright_button(form, "Iterate", iterate_cb, NULL);    iterate=antiright_button(form, "Iterate", iterate_cb, NULL);
     
234    ARCLARG;    ARCLARG;
235    antiright_form_positions(90, 100, 0, 100);    antiright_form_positions(90, 100, 50, 100);
236    refresh=antiright_button(form, "Refresh", expose_cb, NULL);    refresh=antiright_button(form, "Refresh", expose_cb, NULL);
   
237    ARCLARG;    ARCLARG;
238    antiright_form_positions(0, 10, 80, 100);    antiright_form_positions(0, 10, 80, 100);
239    antiright_label(form, "I:");    antiright_label(form, "I:");
240    ARCLARG;    ARCLARG;
241    antiright_form_positions(10, 20, 80, 100);    antiright_form_positions(10, 20, 80, 100);
242    i_field=XmCreateTextField(form, "Iterations",    i_field=XmCreateTextField(form, "Iterations",
243                              antiright.arguments,                              antiright.arguments,
244                              antiright.arguments_int);                              antiright.arguments_int);
245    XtAddCallback(i_field, XmNactivateCallback, i_mvcb, NULL);    XtAddCallback(i_field, XmNactivateCallback, i_mvcb, NULL);
246    XtManageChild(i_field);    XtManageChild(i_field);
     
247    ARCLARG;    ARCLARG;
248    antiright_form_positions(20, 30, 80, 100);    antiright_form_positions(20, 30, 80, 100);
249    antiright_label(form, "T:");    antiright_label(form, "T:");
250    ARCLARG;    ARCLARG;
251    antiright_form_positions(30, 40, 80, 100);    antiright_form_positions(30, 40, 80, 100);
252    t_field=XmCreateTextField(form, "Threshhold",    t_field=XmCreateTextField(form, "Threshhold",
253                              antiright.arguments,                              antiright.arguments,
254                              antiright.arguments_int);                              antiright.arguments_int);
255    XtAddCallback(t_field, XmNactivateCallback, t_mvcb, NULL);    XtAddCallback(t_field, XmNactivateCallback, t_mvcb, NULL);
256    XtManageChild(t_field);    XtManageChild(t_field);
     
257    ARCLARG;    ARCLARG;
258    antiright_form_positions(40, 50, 80, 100);    antiright_form_positions(40, 50, 80, 100);
259    antiright_label(form, "P:");    antiright_label(form, "P:");
# Line 225  main(int argc, char **argv) Line 263  main(int argc, char **argv)
263                        antiright.arguments_int);                        antiright.arguments_int);
264    XtAddCallback(P_field, XmNactivateCallback, p_mvcb, NULL);    XtAddCallback(P_field, XmNactivateCallback, p_mvcb, NULL);
265    XtManageChild(P_field);    XtManageChild(P_field);
     
266    ARCLARG;    ARCLARG;
267    antiright_form_positions(60, 70, 80, 100);    antiright_form_positions(60, 70, 80, 100);
268    antiright_label(form, "Q:");    antiright_label(form, "Q:");
# Line 237  main(int argc, char **argv) Line 274  main(int argc, char **argv)
274    XtManageChild(Q_field);    XtManageChild(Q_field);
275    
276    
277    buffer=XCreatePixmap(antiright.display,    buffer=XCreatePixmap(antiright.display,
278                         antiright.graph.drawing.window,                         antiright.graph.drawing.window,
279                         256, 256,                         384, 384,
280                         DefaultDepth(antiright.display,                         DefaultDepth(antiright.display,
281                                      antiright.screen));                                      antiright.screen));
282    buffer_gc=XCreateGC(antiright.display, buffer, 0, NULL);    buffer_gc=XCreateGC(antiright.display, buffer, 0, NULL);
283    antiright_drawing_initialize(antiright.graph.widget,    antiright_drawing_initialize(antiright.graph.widget,
284                                 &buffer_drawing);                                 &buffer_drawing);
285    buffer_drawing.window=buffer;    buffer_drawing.window=buffer;
286    buffer_drawing.gc=XCreateGC(antiright.display, buffer, 0, NULL);    buffer_drawing.gc=XCreateGC(antiright.display, buffer, 0, NULL);

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26