// Julia_128_custom.cpp cwc // 181225 // g++ Julia_128_custom.cpp -lglut -lGL -o Julia128_custom.o // ./Julia128_custom.o 0.345 0.565 128 4 1 // #include #include "GL/glut.h" #include "GL/gl.h" #include #include using namespace std; // c++ namespace //globals for command line input int colors_arg; int limit_arg; float scale_arg; float c1_arg,c2_arg; float round3(float var) { float value = (int)(var * 1000 + 0,5); return (float)value / 1000; } void plot2D(float x,float y, float red, float green, float blue){ glColor3f(red, green, blue); glVertex2f(x, y); } array,128> buildColors( array,2> colors){ array,128>Colors128; int n; int m=0; // m is the counter float sr,sg,sb,er,eg,eb,ir,ig,ib; for (n =0;n < 2 ; n++){ cout<<"colors n="< 1.0)Colors128[m][0] = 1.0; Colors128[m][1] = Colors128[m-1][1] + ig; if(Colors128[m][1] < 0.0)Colors128[m][1] = 0.0; if(Colors128[m][1] > 1.0)Colors128[m][1] = 1.0; Colors128[m][2] = Colors128[m-1][2] + ib; if(Colors128[m][2] < 0.0)Colors128[m][2] = 0.0; if(Colors128[m][2] > 1.0)Colors128[m][2] = 1.0; m = m + 1; // cout<<" m = "<,2> colors = {{ { 1.0, 1.0 , 1.0}, { 0.149 , 0.545 , 0.0} }}; array,128>colors128 = buildColors(colors); int total_colors = colors_arg; int setcolor = 0; int iterations = 1000; int limit = limit_arg; float h,k; int count,maxcount; float z,x,y,x1,y1,x2,y2,jd,id; // .34567 .5 float c1 = 0.3456; float c2 = 0.5321; c1 = c1_arg; c2 = c2_arg; float red = 1.0,green = 0 ,blue = 0.0; glClearColor(1.0,1.0, 1.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); glPointSize(1.0);// set pixel size glBegin(GL_POINTS);// points // ************************************************************ maxcount = 0; float scale = scale_arg/2.0; for (k = -1.0 ; k <= 1.0 ; k = k + (1.0/800.0)) { y1 = k / scale; for (h = -1.0 ; h <= 1.0; h = h + (1.0/800.0)){ x1 = h / scale; x = x1; y = y1; z = 0.0; count = 0; do { x2 = (x * x) - (y * y) + c1; y = (2 * x * y) + c2; x = x2; z = (x * x) + (y * y); count++; }while ((count <= iterations) & (z < 4.0)); if(count > maxcount)maxcount = count; if (count >= limit) { setcolor = (count % total_colors); red = colors128[setcolor][0]; green= colors128[setcolor][1]; blue = colors128[setcolor][2]; plot2D(h,k,red,green,blue); } }//end for i }//end for j printf("max count %d \n",maxcount); // only change code above this line // ************************************************************ glEnd();//end points glutSwapBuffers();// this draws the points } int main(int argc, char **argv) { cout<< argv[1]<>> 243.0/255.0 0.9529411764705882 >>> 222.0/255.0 0.8705882352941177 >>> 126.0/255.0 0.49411764705882355 */