
{"id":2602,"date":"2010-08-21T23:33:20","date_gmt":"2010-08-21T18:03:20","guid":{"rendered":"http:\/\/www.jeffrin.in\/?p=2602"},"modified":"2010-08-21T23:33:20","modified_gmt":"2010-08-21T18:03:20","slug":"cairo-graphics-0-9-intersection-ii","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2010\/08\/21\/cairo-graphics-0-9-intersection-ii\/","title":{"rendered":"cairo graphics 0.9 intersection II"},"content":{"rendered":"<p><a href=\"https:\/\/beautifulworknew.wordpress.com\/wp-content\/uploads\/2021\/03\/0a468-intersectionascross1.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/beautifulworknew.wordpress.com\/wp-content\/uploads\/2021\/03\/0a468-intersectionascross1.png?w=300\" alt=\"\" title=\"intersectionascross\" width=\"300\" height=\"225\" class=\"alignnone size-medium wp-image-2605\" \/><\/a><br \/>\n<code><br \/>\n\/* Jeffrin Jose  Licensed GPL v3 Copyright<br \/>\nAugust 2010 GPL --&gt; http:\/\/www.gnu.org\/copyleft\/gpl.html *\/<br \/>\n\/\/ module do_draw<\/p>\n<p>\/\/do_draw will be executed in a separate thread whenever we would like to update<br \/>\n\/\/our animation<br \/>\nvoid *do_draw(void *ptr){<\/p>\n<p>    currently_drawing = 1;<\/p>\n<p>    int width, height;<br \/>\n    gdk_threads_enter();<br \/>\n    gdk_drawable_get_size(pixmap, &amp;width, &amp;height);<br \/>\n    gdk_threads_leave();<\/p>\n<p>    \/\/create a gtk-independant surface to draw on<br \/>\n    cairo_surface_t *cst = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);<br \/>\n    cairo_t *cr = cairo_create(cst);<\/p>\n<p>            \/\/Vertical Line<br \/>\n            cairo_move_to(cr, 200,30);<br \/>\n            cairo_line_to(cr,200,200);<\/p>\n<p>            \/\/Horizontal Line<br \/>\n            cairo_move_to(cr, 50,120);<br \/>\n            cairo_line_to(cr,350,120);<\/p>\n<p>    \/\/do some time-consuming drawing<br \/>\n    static int i = 0;<br \/>\n    ++i; i = i % 300;   \/\/give a little movement to our animation<br \/>\n    cairo_set_source_rgb (cr, .9, .9, .9);<br \/>\n    cairo_paint(cr);<br \/>\n            cairo_set_source_rgb (cr, 0.8, 0.5, 0.9);<br \/>\n            cairo_move_to(cr, 50,50);<br \/>\n  int j,k;<br \/>\n\/*    for(k=0; k&lt;100; ++k){*\/   \/\/lets just redraw lots of times to use a lot of proc power<br \/>\n        for(j=0; j &lt; 100; j++){<br \/>\n            cairo_set_source_rgb (cr, 0.8, 0.5, 0.9);<br \/>\n            cairo_move_to(cr, 100,76);<br \/>\n        \/*    cairo_line_to(cr,200+i,100);*\/<br \/>\n\/*  cairo_arc(cr,300+i,100,4,0, 2*M_PI);*\/<br \/>\n\/* cairo_arc(cr,70+i,100,40,0,2*M_PI);*\/<br \/>\n             if ( i &lt; 100)<br \/>\n             cairo_arc(cr, 100+i,76,0,0,0);<br \/>\n        \/*    cairo_rectangle(cr,50+i,50+i,50,50); *\/<\/p>\n<p>            cairo_stroke(cr);<br \/>\n        }<br \/>\n \/*   }*\/<br \/>\n    cairo_destroy(cr);<br \/>\n  \/\/When dealing with gdkPixmap&#039;s, we need to make sure not to<br \/>\n    \/\/access them from outside gtk_main().<br \/>\n    gdk_threads_enter();<\/p>\n<p>    cairo_t *cr_pixmap = gdk_cairo_create(pixmap);<br \/>\n    cairo_set_source_surface (cr_pixmap, cst, 0, 0);<br \/>\n    cairo_paint(cr_pixmap);<br \/>\n    cairo_destroy(cr_pixmap);<\/p>\n<p>    gdk_threads_leave();<\/p>\n<p>    cairo_surface_destroy(cst);<\/p>\n<p>    currently_drawing = 0;<\/p>\n<p>    return NULL;<br \/>\n}<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/* Jeffrin Jose Licensed GPL v3 Copyright August 2010 GPL &#8211;&gt; http:\/\/www.gnu.org\/copyleft\/gpl.html *\/ \/\/ module do_draw \/\/do_draw will be executed in a separate thread whenever we would like to update \/\/our animation void *do_draw(void *ptr){ currently_drawing = 1; int width, height; gdk_threads_enter(); gdk_drawable_get_size(pixmap, &amp;width, &amp;height); gdk_threads_leave(); \/\/create a gtk-independant surface to draw on cairo_surface_t *cst &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2010\/08\/21\/cairo-graphics-0-9-intersection-ii\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;cairo graphics 0.9 intersection II&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[965,1022,1120,1357],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/2602"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=2602"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/2602\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=2602"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=2602"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=2602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}