GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GTK, Cairo, filling routine [SOLVED]

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
satyria
Familiar Face


Joined: 25 Feb 2008
Posts: 18

PostPosted: Mon Sep 22, 2008 10:27 am    Post subject: GTK, Cairo, filling routine [SOLVED] Reply with quote

GTK, Cairo, filling routine

Hello, maybe it is just a small mistake, but I have the following:

When I define an object in cairo and then fill it wants to produce a transferees result(shadow?).

Here my example:


First example shows in red, as I have it in Cairo with cairo_move_to and cairo_line_to have defined (without cairo_fill). The second example shows, when it was filled.

I'd like it if the entire area is filled.

Commands:

Code: (Plaintext)
1
2
3
4
5
6
7
8
9
10
11
12
cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
cairo_set_line_width (cr, 1);
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);

cairo_move_to(cr, x, y);
cairo_line_to(cr, x, y);



cairo_fill (cr);
cairo_stroke (cr);


Last edited by satyria on Fri Sep 26, 2008 12:20 pm; edited 1 time in total
Back to top
satyria
Familiar Face


Joined: 25 Feb 2008
Posts: 18

PostPosted: Fri Sep 26, 2008 9:00 am    Post subject: Reply with quote

Hello,

here is a programm with the normal routines
Code: (C)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{
    cairo_t *cr;
    gint x, y;
    gint w, h;

    x = da->allocation.x;
    y = da->allocation.y;
    w = da->allocation.width;
    h = da->allocation.height;

//The first Circle:

   
cr = gdk_cairo_create(da->window);
        cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
        cairo_set_line_width (cr, 1);
        cairo_arc(cr,50,50,40,0,360* (3.1415 / 180.));
    cairo_stroke(cr);
    cairo_destroy(cr);

        cr = gdk_cairo_create(da->window);
        cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
        cairo_set_line_width (cr, 1);
        cairo_arc(cr,50,50,39,0,360* (3.1415 / 180.));
    cairo_stroke(cr);
    cairo_destroy(cr);

//The second filled circle:

   
cr = gdk_cairo_create(da->window);
        cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
        cairo_set_line_width (cr, 1);
        cairo_arc(cr,150,50,40,0,360* (3.1415 / 180.));
    cairo_stroke(cr);
    cairo_destroy(cr);

        cr = gdk_cairo_create(da->window);
        cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
        cairo_set_line_width (cr, 1);
        cairo_arc(cr,150,50,39,0,360* (3.1415 / 180.));
        cairo_fill (cr);
    cairo_stroke(cr);
    cairo_destroy(cr);

    return TRUE;
}


and the picture:


whence come the empty place?

Greeting Satyria
Back to top
satyria
Familiar Face


Joined: 25 Feb 2008
Posts: 18

PostPosted: Fri Sep 26, 2008 12:22 pm    Post subject: Reply with quote

Hello,

The correct command is: "cairo_fill_preserve"

Satyria
Back to top
dreblen
Never Seen the Sunlight


Joined: 14 Jun 2007
Posts: 426
Location: Falun, WI USA

PostPosted: Fri Sep 26, 2008 3:53 pm    Post subject: Reply with quote

so you got it fixed?

also, I'd like to point out that you don't need to destroy your cairo context after each stroke, you can use the same one throughout the entire
function and then destroy it at the end.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP