I want to draw some static and some dynamic graphics on Gtk drawing area. In Gtk drawing area, on every call of queue_draw, it clears all the graphics already drawn, and for complex graphics this is very time consuming.
Is there a way that I specifically delete some graphics, and add a few new graphics while the already drawn graphics remains undeleted?
for example in image1 , I want to keep black line unchanged unless drawing area window size changes, I want to keep 3 out of 5 red spots and add some new blue spots so that new image looks like image2 .
If this question is already answered please share link.
I know 2 ways to solve your problem.
Store paths . You can draw something (with line_to
, arc
, etc) on an empty cairo_t
, then call cairo_copy_path
and store that path somewhere. On next "draw"
you should call cairo_append_path
to apply that path.
You can store entire cairo surfaces. For example, create cairo_image_surface, fill it and then use it like this:
draw_surface (cairo_surface_t *src, cairo_t *dst, gdouble x, gdouble y) { cairo_surface_mark_dirty (src); cairo_save (dst); cairo_translate (dst, x, y); cairo_set_source_surface (dst, src, 0, 0); cairo_paint (dst); cairo_restore (dst); }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.