Exemplo n.º 1
0
void FractalCreator::run(string name) {
	calculateIteration();
	calculateTotalIterations();
	drawFractal();
	writeBitmap("test.bmp");

}
Exemplo n.º 2
0
void FractalCreator::run(string filename)
{
    addZoom(Zoom(_width/2, _height/2, 4.0/_width));
    addZoom(Zoom(295, _height - 202, 0.1));
    addZoom(Zoom(312, _height - 304, 0.1));

    calculateIteration();
    calculateRangeTotal();
    drawFractal();
    writeBitmap(filename);
}
Exemplo n.º 3
0
void drawFractal(int level, bool isRoot)
{
    if (level < 0)
        return;

    glutWireCube(1.0);

    glPushMatrix();
        glTranslatef(0.0, 0.75, 0.0);
        glScalef(0.75, 0.75, 0.75);
        glRotatef(10.0, 0.0, 0.0, -1.0);
        drawFractal(level - 1, FALSE);
    glPopMatrix();

    if (!isRoot)
        return;

    glPushMatrix();
        glTranslatef(0.75, 0.0, 0.0);
        glScalef(0.75, 0.75, 0.75);
        glRotatef(90, 0.0, 0.0, -1.0);
        glRotatef(10.0, 0.0, 0.0, -1.0);
        drawFractal(level - 1, FALSE);
    glPopMatrix();

    glPushMatrix();
        glTranslatef(0.0, -0.75, 0.0);
        glScalef(0.75, 0.75, 0.75);
        glRotatef(180, 0.0, 0.0, -1.0);
        glRotatef(10.0, 0.0, 0.0, -1.0);
        drawFractal(level - 1, FALSE);
    glPopMatrix();

    glPushMatrix();
        glTranslatef(-0.75, 0.0, 0.0);
        glScalef(0.75, 0.75, 0.75);
        glRotatef(270, 0.0, 0.0, -1.0);
        glRotatef(10.0, 0.0, 0.0, -1.0);
        drawFractal(level - 1, FALSE);
    glPopMatrix();
}
Exemplo n.º 4
0
void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0, 1.0, 1.0);
    glLoadIdentity();
    gluLookAt(0.0, 0.0, 5.0, // Eye position
              0.0, 0.0, 0.0, // Looking at
              0.0, 1.0, 0.0); // With normal vector
    glRotatef(30.0, 0.0, 0.0, -1.0);
    drawFractal(15, TRUE);
    glFlush();
}
Exemplo n.º 5
0
/*
 * drawScene() handles the animation and the redrawing of the
 *		graphics window contents.
 */
void drawScene(void)
{
	// Clear the rendering window

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Set drawing color to white
	glColor3f( 1.0, 1.0, 1.0 );		

	if (mode == 1) {
        glMatrixMode(GL_MODELVIEW);
    	glLoadIdentity();
		drawFractal(CurrentNum);
	} else if (mode == 2) {
		drawProbabilisticFractal(CurrentProbabilisticNum);
	} 

 // Flush the pipeline.  (Not usually necessary.)
	glFlush();
}
Exemplo n.º 6
0
int main()
{
	int numFractals;    
    scanf("%d", &numFractals);
    
    int depth;
    double angle, heading;
    char axiom[MAX_CHARS];
    
    bmp = bmp_create(300 * numFractals, 300, 32);
    resetImage(300 * numFractals, 300);
    
    int i;
    for (i = 0; i < numFractals; i++)
    {
        scanf("%d", &depth);
        scanf("%lf", &angle); 
        scanf("%lf", &heading);
        
        angle = degreesToRadians(angle);
        currH = degreesToRadians(heading);
        
        scanf("%s", axiom);
        scanf("%d", &numRules);
        
        int j;
        for (j = 0; j < numRules; j++)
        {
            char tmp[2];
            scanf("%s -> %s\n", tmp, rules[j]);
            codes[j] = tmp[0];
        }
        
        drawFractal(axiom, heading, angle, depth, i);
    }
    
    bmp_save(bmp, "output.bmp");
	bmp_destroy(bmp);
}
Exemplo n.º 7
0
void drawFractal(int num, int color = 0)
{
	if (color == 0) {
		glColor3f(1.0f, 1.0f, 1.0f);
	} else if (color == 1) {
		glColor3f(1.0f, 0.0f, 0.0f);
	} else if (color == 2) {
		glColor3f(0.0f, 1.0f, 0.0f);
	} else if (color == 3 ) {
		glColor3f(0.0f, 0.0f, 1.0f);
	} else if (color == 4 ) {
		glColor3f(0.0f, 1.0f, 1.0f);
	} else {
		glColor3f(1.0f, 0.0f, 1.0f);
	}
	
switch(num) {
   case 0:
		glBegin( GL_QUADS );
		glVertex3f(0.0f, 0.0f, 0.0f);
		glVertex3f(0.0f, 1.0f, 0.0f);
		glVertex3f(1.0f, 1.0f, 0.0f);
		glVertex3f(1.0f, 0.0f, 0.0f);
		
		glEnd();
        break;
   default:

	   bool firstTime;
	   if (num == CurrentNum ) {
		   firstTime = true;
	   } else {
		   firstTime = false;
		}


        glPushMatrix();
		glPushMatrix();
        glPushMatrix();

        glScalef(0.5f, 0.5f, 1.0f);
		if (firstTime) {
			drawFractal(num - 1, 1);
		} else {
			drawFractal(num - 1, color);
		}
		
        glPopMatrix();
        glScalef(0.5f, 0.5f, 1.0f);
        glTranslatef(0, 2, 0.0f);
		//glRotatef(180, 0, 1, 0);
		glRotatef(180, 0, 1, 0);
		glRotatef(180, 0, 0, 1);
		if (firstTime) {
			drawFractal(num - 1, 2);
		} else {
			drawFractal(num - 1, color);
		}
		
        glPopMatrix();
        glScalef(0.5, 0.5, 1.0);
        glTranslatef(1, 1, 0);
		glRotatef(270, 0, 0, 1);
		if (firstTime) {
			drawFractal(num - 1, 3);
		} else {
			drawFractal(num - 1, color);
		}
		
		glPopMatrix();
        glTranslatef(1, 0.75, 0);
        glScalef(0.25,0.25, 1);
		//glRotatef(180, 1, 0, 0);
		glRotatef(180, 0, 1, 0);
		glRotatef(270, 0, 0, 1);
        if (firstTime) {
			drawFractal(num - 1, 4);
		} else {
			drawFractal(num - 1, color);
		}
		
        break;   
 }
}