@@ -26,8 +26,8 @@ short toPrec(double f, int bitsPrecision)
26
26
}
27
27
#endif
28
28
29
- static const int width = 64 ; /* basic width of a zx81 */
30
- static const int height = 32 ; /* basic width of a zx81 */
29
+ static const int width = 64 ; /* basic width */
30
+ static const int height = 32 ; /* basic width */
31
31
static const int zoom = 1 ; /* leave at 1 for 32x22 */
32
32
33
33
int main (int argc , char * argv [])
@@ -41,17 +41,17 @@ int main(int argc, char *argv[])
41
41
const short LIMIT = 0x100 ; /* toPrec(4, bitsPrecision) */
42
42
43
43
/* fractal */
44
- char charset [] = ".:-=X$#@. " ;
45
- short max_iter = sizeof (charset ) - 1 ;
44
+ char charset [] = ".:-=X$#@ " ;
45
+ const short max_iter = sizeof (charset ) - 1 ;
46
46
47
47
for (short py = 0 ; py < height * zoom ; py ++ ) {
48
48
for (short px = 0 ; px < width * zoom ; px ++ ) {
49
49
short x0 = ((px * X1 ) / width ) - X2 ;
50
50
short y0 = ((py * Y1 ) / height ) - Y2 ;
51
51
short x = 0 , y = 0 ;
52
52
53
- short i = 0 ;
54
- while (i < max_iter ) {
53
+ short i ;
54
+ for (i = 0 ; i < max_iter ; i ++ ) {
55
55
short xSqr = (x * x ) >> bitsPrecision ;
56
56
short ySqr = (y * y ) >> bitsPrecision ;
57
57
@@ -63,16 +63,14 @@ int main(int argc, char *argv[])
63
63
* and we see nothing. By including the overflow break out we
64
64
* can see the fractal again though with noise.
65
65
*/
66
- if ((xSqr + ySqr ) >= LIMIT || ( xSqr + ySqr ) < 0 )
66
+ if ((xSqr + ySqr ) >= LIMIT )
67
67
break ;
68
68
69
69
short xt = xSqr - ySqr + x0 ;
70
70
y = (((x * y ) >> bitsPrecision ) * 2 ) + y0 ;
71
71
x = xt ;
72
-
73
- i ++ ;
74
72
}
75
- printf ("%c " , charset [-- i ]);
73
+ printf ("\033[48;05;%dm%c\033[0m " , i , charset [i - 1 ]);
76
74
}
77
75
78
76
printf ("\n" );
0 commit comments