xref: /haiku/src/add-ons/screen_savers/ifs/IFS.h (revision f2b4344867e97c3f4e742a1b4a15e6879644601a)
1 // Polygon.h
2 
3 #ifndef IFS_H
4 #define IFS_H
5 
6 #include <Screen.h>
7 #include <Point.h>
8 #include <Rect.h>
9 #include <Region.h>
10 #include <View.h>
11 
12 typedef struct Similitude_Struct	SIMI;
13 typedef struct Fractal_Struct		FRACTAL;
14 
15 #define FIX 12
16 #define UNIT   ( 1<<FIX )
17 #define MAX_SIMI  6
18 
19 // settings for a PC 120Mhz...
20 #define MAX_DEPTH_2  10
21 #define MAX_DEPTH_3  6
22 #define MAX_DEPTH_4  4
23 #define MAX_DEPTH_5  3
24 
25 struct buffer_info {
26 	void*			bits;
27 	uint32			bytesPerRow;
28 	uint32			bits_per_pixel;
29 	color_space		format;
30 	clipping_rect	bounds;
31 };
32 
33 struct Point {
34 	int32		x;
35 	int32		y;
36 };
37 
38 struct Similitude_Struct {
39 
40 	float		c_x, c_y;
41 	float		r, r2, A, A2;
42 	int32		Ct, St, Ct2, St2;
43 	int32		Cx, Cy;
44 	int32		R, R2;
45 };
46 
47 struct Fractal_Struct {
48 
49 	int			Nb_Simi;
50 	SIMI		Components[5 * MAX_SIMI];
51 	int			Depth, Col;
52 	int			Count, Speed;
53 	int			Width, Height, Lx, Ly;
54 	float		r_mean, dr_mean, dr2_mean;
55 	int			Cur_Pt, Max_Pt;
56 	Point*		buffer1;
57 	Point*		buffer2;
58 	BBitmap*	bitmap;
59 	BBitmap*	markBitmap;
60 };
61 
62 class IFS {
63  public:
64 								IFS(BRect bounds);
65 	virtual						~IFS();
66 
67 			void				Draw(BView* view, const buffer_info* info,
68 									 int32 frames);
69 
70 			void				SetAdditive(bool additive);
71 			void				SetSpeed(int32 speed);
72 
73  private:
74 			void				_DrawFractal(BView* view,
75 											 const buffer_info* info);
76 			void				_Trace(FRACTAL* F,
77 									   int32 xo, int32 yo);
78 			void				_RandomSimis(FRACTAL* f,
79 											 SIMI* cur,
80 											 int i) const;
81 			void				_FreeBuffers(FRACTAL* f);
82 			void				_FreeIFS(FRACTAL* f);
83 
84 
85 			FRACTAL*			fRoot;
86 			FRACTAL*			fCurrentFractal;
87 			Point*				fPointBuffer;
88 			int32				fCurrentPoint;
89 
90 			bool				fAdditive;
91 			uint8				fCurrentMarkValue;
92 };
93 
94 #endif // ABOUT_VPOLYGON_HIEW_H
95