示例#1
0
int			triangle(t_all *all)
{
	int	nb;

	if (AH->init_fractal)
		init_first_triangle(all);
	init_triangle(all);
	while (++(AF->iter) <= AF->iter_max)
	{
		color_pixel(all, AF->iter);
		if ((nb = abs(rand() % 3)) == 0)
		{
			AP->x = ((AP->x + AF->x1) / 2.0) + AH->motion;
			AP->y = ((AP->y + AF->y1) / 2.0) - AH->motion;
		}
		else if (nb == 1)
		{
			AP->x = ((AP->x + AF->x2) / 2.0) - AH->motion;
			AP->y = ((AP->y + AF->y2) / 2.0) + AH->motion;
		}
		else if (nb == 2)
		{
			AP->x = ((AP->x + AF->x3) / 2.0) + AH->motion;
			AP->y = ((AP->y + AF->y3) / 2.0) - AH->motion;
		}
	}
	return (0);
}
示例#2
0
int main(int argc, char** argv) {

    struct Square square;
    struct Circle circle;
    struct Triangle triangle;

    init_square(&square, 2);
    init_circle(&circle, 4);
    init_triangle(&triangle, 3, 4, 5);

    struct Shape * shapes[3];
    shapes[0] = (struct Shape *) &square;
    shapes[1] = (struct Shape *) &circle;
    shapes[2] = (struct Shape *) &triangle;

    int i;
    for (i = 0; i < 3; ++i) {
        (*shapes[i]).print();
        printf("area: %f\n", (*shapes[i]).area(shapes[i]));
        printf("perimeter: %f\n\n", (*shapes[i]).perimeter(shapes[i]));
    }
    return (EXIT_SUCCESS);
}
示例#3
0
ENTRYPOINT void
reshape_triangle(ModeInfo * mi, int width, int height)
{
    XClearWindow (MI_DISPLAY (mi), MI_WINDOW(mi));
    init_triangle (mi);
}