1 /* Draw a Mandelbrot set, maximum magnification 10000000 times;
12 const int AppletWidth = 3200;
13 const int AppletHeight = 3200;
15 const float amin = (float)-2.0;
16 const float amax = (float)1.0;
17 const float bmin = (float)-1.5;
18 const float bmax = (float)1.5;
19 const float alen = (float)3.0;
20 const float blen = (float)3.0;
21 const int times = 255;
32 int main(int argc, char **argv) {
41 length = AppletWidth * AppletHeight;
42 pixels = (int*)malloc(sizeof(int) * length);;
44 while (incr < length) {
45 pixels[incr++] = alpha<<24 | 0x00<<16 | 0x00<<8 | 0xff;
47 int maxint = RAND_MAX;
48 red = (int)(((float)rand()/maxint)*255);
49 green = (int)(((float)rand()/maxint)*255);
50 blue = (int)(((float)rand()/maxint)*255);
56 raw_test_pass(raw_get_cycle());
62 float a,b,x,y; //a--width, b--height
64 float adelta = (float)(alen/AppletWidth);
65 float bdelta = (float)(blen/AppletHeight);
66 for(a=amin;a<amax;a+=adelta) {
67 for(b=bmin;b<bmax;b+=bdelta) {
71 float x2 = (float)0.0;
72 float y2 = (float)0.0;
73 float xy = (float)0.0;
74 int finish = 1; //(x2 + y2 <= 4.0) & (iteration != times);
76 float tmpy = (float)2.0*xy;
83 int tmpf = (x2 + y2 <= 4.0);
84 finish = tmpf & (iteration != times);
86 if(iteration<=times & iteration>0) {
87 scaleda=(int)((a - amin)*AppletWidth/(amax - amin));
88 scaledb=(int)((b - bmin)*AppletHeight/(bmax - bmin));
89 int index = scaledb * AppletWidth + scaleda;
90 pixels[index] = alpha<<24 | red<<16 | iteration<<8 | blue;