-
Notifications
You must be signed in to change notification settings - Fork 0
/
julia.cpp
80 lines (71 loc) · 1.87 KB
/
julia.cpp
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
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
using namespace std;
#define CR 0.75
#define CC -0.12
extern "C" bool julia(double,double,double,double);
extern "C" void set_n(int);
int main(int argc, char **argv)
{
double cc = CC;
double cr = CR;
double scale=1.000;
int pixel_count=0;
double center_x_offset=0;
double center_y_offset=0;
int iterations=32;
printf( "\n ASCII Julia - (C) 2019 - Michael K. Pellegrino - [email protected]\n");
switch( argc )
{
case 7:
if( atof(argv[6]) == 0 )
{
iterations=32;
}
else
{
iterations=atof( argv[6] );
}
case 6:
center_x_offset=atof( argv[5] );
center_y_offset=atof( argv[4] );
case 4:
scale=atof( argv[3] );
case 3:
cr=atof( argv[1] );
cc=atof( argv[2] );
case 1:
printf( "Params: CR: %lf, CC %lf, Zoom: %lf, ctr: (%lf,%lf), n=%d\n", cr, cc, scale, center_x_offset, center_y_offset, iterations );
break;
default:
printf( "Requires 0,2,3,5, or 6 numeric inputs.\n" );
printf( "%s C_real C_imag ZoomFactor CtrX CtrY iterations\n", argv[0] );
printf( "Try:\n" );
printf( "%s 1.0397 0.1528 200 22 3 10\n", argv[0] );
printf( "%s -0.435 0.624 2\n", argv[0] );
printf( "%s 0.8 -0.1 2.35\n", argv[0] );
printf( "%s 1 0.12 1.1\n", argv[0] );
printf( "%s 0.75 -0.12 8.2\n", argv[0] );
exit(-1);
}
for( int i=0; i<82; i++ ) printf( "=" ); printf( "\n" );
set_n(iterations);
for( double i=(-2-center_x_offset); i<=(2-center_x_offset); i+=0.05 )
{
printf( "|" );
for( double j=(2-center_y_offset); j>=(-2-center_y_offset); j-=0.05 )
{
if( julia(i/scale,j/scale,cr,cc)>0 )
{
printf( "*" );
}
else
{
printf( " " );
}
}
printf( "|\n" );
}
for( int i=0; i<82; i++ ) printf( "=" ); printf( "\n" );
}