college/ws2010/gdi3/Praktikum/mandelbrot_vorgabe.cpp
2011-10-24 10:02:02 +02:00

72 lines
1.2 KiB
C++

/*
* mandelbrot_vorgabe.cpp
*
* Created on: 10.01.2011
* Author: mk
*/
#define ASCII_WIDTH 50
#define ASCII_HEIGHT 35
class CMandelbrot
{
public:
CMandelbrot();
int getASCIImapPoint(int pX, int pY){return asciimap[pX][pY];}
void setASCIImapPoint(int pX, int pY, int pValue){asciimap[pX][pY]=pValue;}
private:
int asciimap[ASCII_WIDTH][ASCII_HEIGHT];
double minRe,maxRe,minIm;
};
class CPainter
{
public:
CPainter();
private:
void printASCIIMandelbrot();
};
/*
* returns the Mandelbrot-set as ASCII-art on the command line
*/
void CPainter::printASCIIMandelbrot()
{
for(int i=0;i<ASCII_HEIGHT;i++)
{
for(int j=0;j<ASCII_WIDTH;j++)
if(mandelbrot->getASCIImapPoint(j,i)==0)
printf(" ");
else
printf("X");
printf("\n");
}
}
/*
* creates a new CMandelbrot object
*/
CMandelbrot::CMandelbrot()
{
maxRe = 1.0;
minIm = -1.2;
minRe = -2.0;
}
/*
* check arguments, create all necessary objects
*/
int main(int argc, char* argv[])
{
// argv[1] = number of iterations
// argv[2] = output mode [0 = disabled; 1 = ASCII]
if (argc<3)
{
printf("wrong number of arguments:\n1. number of iterations\n2. output mode [0 = disabled; 1 = ASCII]\n");
return -1;
}
return 0;
}