cairo graphics 0.1 (line)



#include
#include

int i=0;

static gboolean
draw(GtkWidget *widget,
GdkEventExpose *event,
gpointer data)
{
cairo_t *cr;

cr = gdk_cairo_create(widget->window);

cairo_set_source_rgb(cr, 0, 0, 0);
cairo_set_line_width (cr, 0.5);

/*for (i=0;i<200;i++)
{ */
cairo_move_to(cr,30,60);
/* cairo_line_to(cr,30+i,60+i);*/
cairo_line_to(cr,40,200);

cairo_stroke(cr);
/* cairo_surface_flush(); */
/* usleep(100000);*/
/*} */
cairo_destroy(cr);

return FALSE;
}

int

main (int argc, char *argv[])
{

GtkWidget *window;

gtk_init(&argc, &argv);

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

gtk_widget_add_events (window, GDK_BUTTON_PRESS_MASK);

g_signal_connect(window, "expose-event",
G_CALLBACK(draw), NULL);
g_signal_connect(window, "destroy",
G_CALLBACK(gtk_main_quit), NULL);

gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_window_set_title(GTK_WINDOW(window), "lines");
gtk_window_set_default_size(GTK_WINDOW(window), 400, 300);
gtk_widget_set_app_paintable(window, TRUE);

gtk_widget_show_all(window);

gtk_main();

return 0;
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *