Exemplo n.º 1
0
void zeichne(cairo_t *cr, const double x1, const double y1, const double x2, const double y2, 
	const double x3, const double y3, const unsigned tiefe) {
	if (tiefe <= 0) {
		triangle(cr, x1, y1, x2, y2, x3, y3);
		return;
	}
	zeichne(cr, x1, y1, (x1 + x2) / 2, (y1 + y2) / 2, 
		(x1 + x3) / 2, (y1 + y3) / 2, tiefe - 1);
	zeichne(cr, (x1 + x2) / 2, (y1 + y2) / 2, x2, y2,
		(x2 + x3) / 2, (y2 + y3) / 2, tiefe - 1);
	zeichne(cr, (x1 + x3) / 2, (y1 + y3) / 2, 
		(x2 + x3) / 2, (y2 + y3) / 2, x3, y3, tiefe - 1);
}
Exemplo n.º 2
0
int main() {
	// Auflösung in Pixeln
	const double res = 1000;
	const double xsize = res;
	const double ysize = sin(M_PI / 3) * res;

	// Breite einer Linie in Pixeln
	const double line_width = 3;

	// maximale Anzahl Iterationen
	const unsigned int iterations = 7;

	cairo_surface_t *surface = cairo_image_surface_create (
    	CAIRO_FORMAT_ARGB32, xsize, ysize);
    cairo_t *cr = cairo_create (surface);

    cairo_scale(cr, res, res);

    cairo_set_line_width (cr, line_width / res);
	cairo_set_source_rgb (cr, 0, 0, 0);

	const double space = 0.05;

	zeichne(cr, space, sin(M_PI / 3) - space, 1 - space,
		sin(M_PI / 3) - space, 0.5, space, iterations);

	cairo_destroy (cr);
    cairo_surface_write_to_png (surface, "sierpinski.png");
    cairo_surface_destroy (surface);
		
	return 0;
}
Exemplo n.º 3
0
int main()
{
    Linie l;
    Kreis k, k1, k2;

    zeichne(l);            // zeichne(GeoObj&) => Linie::draw()
    zeichne(k);            // zeichne(GeoObj&) => Kreis::draw()

    abstand(k1,k2);        // abstand(GeoObj&,GeoObj&)
    abstand(l,k);          // abstand(GeoObj&,GeoObj&)

    std::vector<GeoObj*> menge;  // inhomogene Menge
    menge.push_back(&l);         // Linie einfügen
    menge.push_back(&k);         // Kreis einfügen
    ausgeben(menge);             // Menge ausgeben
}
Exemplo n.º 4
0
/* ************************************************************* */
int next_zeit_cb()
/* ************************************************************* */
{
	char c_zeit[10];
	int eq = 0;
	g_animation.anim_frame = (g_animation.anim_frame) ? g_animation.anim_frame : 1;
	if (( eq = g_animation.akt_index % g_animation.anim_frame ) == 0)
	{
		lese_next_zeit();
		glMatrixMode (GL_PROJECTION);
		glLoadIdentity ();
		C3D_updateref();
		zeichne();
		sprintf(c_zeit, "%8.3f", g_animation.zeiten[g_animation.akt_index]);
		XmTextFieldSetString(widgetMain.T_zeitschritt, c_zeit);
		return 1;
	}
	else
	{
		/* increase actual index frame */
		if(g_animation.akt_index >= g_animation.anim_ende)
			g_animation.akt_index = g_animation.anim_anfang;
		else
			g_animation.akt_index++;
		return 0;
	}

/* ************************************************************* */
}