Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/include/fractal.h
blob: 188ac8d45cfad4c1b9ad4706b77c21daaba9c9b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
79
80
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/* 
 *     XaoS, a fast portable realtime fractal zoomer 
 *                  Copyright (C) 1996,1997 by
 *
 *      Jan Hubicka          (hubicka@paru.cas.cz)
 *      Thomas Marsh         (tmarsh@austin.ibm.com)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (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
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
#ifndef FRACTAL1_H
#define FRACTAL1_H

#ifdef __cplusplus
extern "C" {
#endif

#include "config.h"
#include "fconfig.h"
#define INCOLORING 11
#define OUTCOLORING 11
#define TCOLOR 15

    typedef struct {
	number_t y0, k;
    } symetrytype;

    struct symetryinfo {
	number_t xsym, ysym;
	int nsymetries;
	CONST symetrytype *symetry;
    };
    typedef struct {
	number_t mc, nc;
	number_t mi, ni;
    } vrect;
    typedef struct {
	number_t cr, ci;
	number_t rr, ri;
    } vinfo;
    typedef unsigned int (*iterationfunc) (number_t, number_t, number_t,
					   number_t) CONSTF REGISTERS(3);
    struct formula {
	int magic;
#ifndef SLOWFUNCPTR
	iterationfunc calculate, calculate_periodicity, smooth_calculate,
	    smooth_calculate_periodicity;
#endif
	void (*calculate_julia) (struct image * img, register number_t pre,
				 register number_t pim);
	CONST char *name[2];
	CONST char *shortname;
	vinfo v;
	int hasperiodicity;
	int mandelbrot;
	number_t pre, pim;
	struct symetryinfo (out[OUTCOLORING + 1]);
	struct symetryinfo (in[INCOLORING + 1]);
	int flags;
    };

    struct fractal_context {
	number_t pre, pim;
	number_t bre, bim;
	CONST struct formula *currentformula;
	number_t angle;
	int periodicity;
	unsigned int maxiter;
	number_t bailout;
	int coloringmode, incoloringmode;
	int intcolor, outtcolor;
	int mandelbrot;
	int plane;
	int version;
	int range;
	float windowwidth, windowheight;
	vinfo s;
	vrect rs;
	number_t sin, cos;
	int slowmode;		/* 1 in case we want to be exact, not fast */
	/*values temporary filled by set_fractal_context */
	iterationfunc calculate[2];
	number_t periodicity_limit;
	struct palette *palette;	/*fractal's palette */
    };
    typedef struct fractal_context fractal_context;
    typedef struct {
	double y0, k, kk, y0k;
    } symetry2;

    struct symetryinfo2 {
	number_t xsym, ysym;
	int nsymetries;
	symetry2 *symetry;
	number_t xmul, ymul, xdist, ydist;
    };
#define STARTZERO 1
#define JULIA_BTRACE 2
#define MANDEL_BTRACE 4

#ifdef SFFE_USING
#define SFFE_FRACTAL 8
#endif

#define BTRACEOK ((cformula.flags&(2<<cfractalc.mandelbrot))&&!cfractalc.incoloringmode&&cfractalc.coloringmode!=7)
#define rotate(f,x,y) { \
  number_t tmp; \
  tmp=(x)*(f).cos-(y)*(f).sin; \
  y=(x)*(f).sin+(y)*(f).cos; \
  x=tmp; \
}
#define rotateback(f,x,y) { \
  number_t tmp; \
  tmp=(x)*(f).cos+(y)*(f).sin; \
  y=-(x)*(f).sin+(y)*(f).cos; \
  x=tmp; \
}

    extern struct symetryinfo2 cursymetry;
    extern struct fractal_context cfractalc;
    extern struct formula cformula;
    extern struct palette cpalette;
    extern struct image cimage;

#ifdef STATISTICS
/*This is an statistics variables printed from various parts
 *of XaoS. 
 */
    extern int nadded2, nsymetry2, nskipped2;
    extern int tocalculate2, avoided2, frames2;
    extern int ncalculated2, ninside2;
    extern int niter2, niter1;
    extern int nperi;


    extern int iters2, guessed2, unguessed2, total2;

#endif

    void set_formula(fractal_context *, int);
    void set_fractalc(fractal_context *, struct image *img);
    void fractalc_resize_to(fractal_context *, float, float);
    void update_view(fractal_context *);
    void free_fractalc(fractal_context *);
    fractal_context *make_fractalc(CONST int, float, float);
    void speed_test(fractal_context *, struct image *img);
    unsigned int calculateswitch(register number_t x1,
				 register number_t y1,
				 register number_t x2,
				 register number_t y2,
				 int periodicity) REGISTERS(3);

/* needs struct formula */
#include <formulas.h>

#ifdef __cplusplus
}
#endif
#endif				/* FRACTAL_H */