6 ___________________________________________________________________
7 | Julia Set for -0.34 - 0.63i :. |
10 | :':::.. '' ::. .. :.' |
11 | '::::. :: :::. . :.'': . |
12 | ......':::.::.:: ...::.:::.::.. . |
13 | :::::::::':'.':.::::::::':.::''::.. |
14 | . '::::'':':::':'':::' ::'' ' |
15 | ':. . .. ..::'::':::. ' :' |
16 | . :: :' ::..::::::: ::: ':::.. ' |
17 | :':::: '.:::::::::'.::::' '' |
18 | .:::::' ':::::::::. ''::::'. |
19 | :. '::::'.::::::::::. '::':.' |
20 | . . '':::. ::: ::::::::'::' .:::: |
21 | :':. ... ':::.:':::'' ' ' ''. |
22 | ..:: .::::::...':.::::::.: |
23 | :::...' '.::::::::'.: .:.:'::::'': |
24 | '' :. : .:''':' :::'::':::. ' ' |
25 | '::'': '' '::: ::''::::: |
30 |___________________________________________________________________|
36 The following code is a simple [C](c.md) program that renders given Julia set into terminal (for demonstrative purposes, it isn't efficient or do any [antialiasing](antialiasing.md)).
43 #define SET_X -0.36 // Julia set parameter
44 #define SET_Y -0.62 // Julia set parameter
47 #define STEP (3.0 / ((double) COLS))
49 unsigned int julia(double x, double y)
51 double cx = x, cy = y, tmp;
53 for (int i = 0; i < 1000; ++i)
55 tmp = cx * cx - cy * cy + SET_X;
56 cy = 2 * cx * cy + SET_Y;
59 if (cx * cx + cy * cy > 10000000000)
68 double cx, cy = FROM_Y;
70 for (int y = 0; y < ROWS; ++y)
74 for (int x = 0; x < COLS; ++x)
77 julia(cx,cy) + (julia(cx,cy + STEP) * 2);
79 putchar(point == 3 ? ':' : (point == 2 ? '\'' :
80 (point == 1 ? '.' : ' ')));