int main(int argc,char *argv[]) { png::rgb_pixel black = png::rgb_pixel(0,0,0); //default resolution int xres=1920; int yres=1080; //default size of the pixel int pixsize=10; // 0 - Original colors, 100 - Complete desaturation int saturation=0; //Color multiplier value int colormult=1; //seed int seed=time(NULL); //if wallstrue equals zero then there will be no walls, else there will be walls int wallstrue=1; char * name="maze.png"; //true if user picks the colors bool setColor=false; std::string userColor; for (int i=1;i<argc;i++) { std::string flag=argv[i]; if (flag=="-w"||flag=="--width") xres=std::stoi(argv[i+1]); if (flag=="-h"||flag=="--height") yres=std::stoi(argv[i+1]); if (flag=="-p"||flag=="--pixel-size") pixsize=std::stoi(argv[i+1]); if (flag=="-b"||flag=="--walls") wallstrue=std::stoi(argv[i+1]); if (flag=="-n"||flag=="--file-name") name=argv[i+1]; if (flag=="-d"||flag=="--desaturation") saturation=std::stoi(argv[i+1]); if (flag=="-t"||flag=="--color-multiplier") colormult=std::stoi(argv[i+1]); if (flag=="-s"||flag=="--seed") seed=std::stoi(argv[i+1]); if (flag=="-c"||flag=="--set-color") { setColor=true; userColor=argv[i+1]; } } //ignores drawing walls if pixel size is 1 if (pixsize==1) wallstrue=0; Draw xwin(pixsize,xres,yres); int xblocks=xwin.screenwidth/xwin.pixwidth-1; int yblocks=xwin.screenheight/xwin.pixwidth-1; Maze maze(xblocks,yblocks); maze.startCreation(seed); maze.nextStep(); int colors[6]; if (setColor==false) { for (int i=0;i<6;i++) { colors[i]=rand()%256; } double distance =sqrt( pow((colors[0]-colors[3]),2) + pow((colors[1]-colors[4]),2) + pow((colors[3]-colors[5]),2)); while (distance<200|distance>300) { for (int i=0;i<6;i++) colors[i]=rand()%256; distance =sqrt( pow((colors[0]-colors[3]),2) + pow((colors[1]-colors[4]),2) + pow((colors[3]-colors[5]),2)); } desaturate(saturation / 100.0, &colors[0], &colors[1], &colors[2]); desaturate(saturation / 100.0, &colors[3], &colors[4], &colors[5]); } else { for (int i=0;i<12;i+=2) { unsigned int col; std::stringstream ss; ss << std::hex << std::string(userColor.begin()+i,userColor.begin()+i+2); ss >> col; colors[i/2]=col; } } maze.drawValues(&xwin,colors[0],colors[1],colors[2],colors[3],colors[4],colors[5],colormult); if (wallstrue!=0) { //horizontal drawWall(maze.wall.horwalls,maze.wall.width,maze.wall.height,&xwin,black,1.0,1.0/2.0,0); //verticle drawWall(maze.wall.vertwalls,maze.wall.width+1,maze.wall.height-1,&xwin,black,1.0/2.0,1.0,1); } xwin.writePng(name); return 0; }
int main(int argc,char *argv[]) { char green[] ="#00FF00"; char red[] ="#ff0000"; char white[]="#FFFFFF"; char black[]="#000000"; int xres=1920; int yres=1080; int pixsize=10; //if wallstrue equals zero then there will be no walls, else there will be walls int wallstrue=1; char * name="maze.png"; //if (argc>1) //xres=std::stoi(argv[1]); //if (argc>2) //yres=std::stoi(argv[2]); //if (argc>3) //pixsize=std::stoi(argv[3]); //if (argc>4) //wallstrue=std::stoi(argv[4]); //if (argc>5) //name=argv[5]; for (int i=1;i<argc;i++) { std::string flag=argv[i]; if (flag=="-w"||flag=="--width") xres=std::stoi(argv[i+1]); if (flag=="-h"||flag=="--height") yres=std::stoi(argv[i+1]); if (flag=="-p"||flag=="--pixel-size") pixsize=std::stoi(argv[i+1]); if (flag=="-b"||flag=="--walls") wallstrue=std::stoi(argv[i+1]); if (flag=="-n"||flag=="--file-name") name=argv[i+1]; } Draw xwin(pixsize,xres,yres); int xblocks=xwin.screenwidth/xwin.pixwidth-1; int yblocks=xwin.screenheight/xwin.pixwidth-1; Maze maze(xblocks,yblocks); //1 means it loops maze.startCreation(1); maze.nextStep(); if (wallstrue!=0) { //horizontal drawWall(maze.wall.horwalls,maze.wall.width,maze.wall.height,&xwin,black,1.0,1.0/2.0,0); //verticle drawWall(maze.wall.vertwalls,maze.wall.width+1,maze.wall.height-1,&xwin,black,1.0/2.0,1.0,1); } // drawBlock(maze.xpos,maze.ypos,&xwin,&maze,red_gc); int colors[6]; for (int i=0;i<6;i++) { colors[i]=rand()%256; } double distance =sqrt( pow((colors[0]-colors[3]),2) + pow((colors[1]-colors[4]),2) + pow((colors[3]-colors[5]),2)); while (distance<200|distance>300) { for (int i=0;i<6;i++) colors[i]=rand()%256; distance =sqrt( pow((colors[0]-colors[3]),2) + pow((colors[1]-colors[4]),2) + pow((colors[3]-colors[5]),2)); } maze.drawValues(&xwin,colors[0],colors[1],colors[2],colors[3],colors[4],colors[5]); // maze.drawValues(&xwin,255,255,255,0,0,0); xwin.writePng(name); // xwin.printPoints(); // xwin.drawScene(); xwin.clearStack(); return 0; }