/* Create a new surface of the appropriate size to store our scribbles */ staticvoid
resize_cb (GtkWidget *widget, int width, int height,
gpointer data)
{ if (surface)
{
cairo_surface_destroy (surface);
surface = NULL;
}
/* Initialize the surface to white */
clear_surface ();
}
}
/* Redraw the screen from the surface. Note that the draw *callbackreceivesaready-to-be-usedcairo_tthatisalready *clippedtoonlydrawtheexposedareasofthewidget
*/ staticvoid
draw_cb (GtkDrawingArea *drawing_area,
cairo_t *cr, int width, int height,
gpointer data)
{
cairo_set_source_surface (cr, surface, 0, 0);
cairo_paint (cr);
}
/* Draw a rectangle on the surface at the given position */ staticvoid
draw_brush (GtkWidget *widget, double x, double y)
{
cairo_t *cr;
/* Paint to the surface, where we store our state */
cr = cairo_create (surface);
cairo_rectangle (cr, x - 3, y - 3, 6, 6);
cairo_fill (cr);
cairo_destroy (cr);
/* Now invalidate the drawing area. */
gtk_widget_queue_draw (widget);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.