Re: Circles and DrawingAreas

The following should do it:

    $drawing_area = Gtk::DrawingArea->new();
    $my_gc = new Gtk::Gdk::GC $drawing_area->window;
    $my_gc->set_foreground(get_color($colormap, "red"));

    $drawing_area->window->draw_arc($my_gc, 1,
                                    $cx-3,$cy-3, 7,7, 0,360*64);


        my %allocated_colors;
        sub get_color {
            my ($gc, $name) = @_;
            my $ret;

            if ($ret = $allocated_colors{$gc . $name}) {
                 return $ret;

            $ret = $gc->color_alloc(Gtk::Gdk::Color->parse_color($name));
            $allocated_colors{$gc . $name} = $ret;
            return $ret;
Excuse the ugliness in the use of the hash table above... 


On Sun, Jul 22, 2001 at 07:58:31PM -0500, Fannin, David P. wrote:
Has anyone out there successfully created a circle and placed it inside a
DrawingArea?  I'm almost finished with a project, and what I thought was
going to be a trivial final detail is turning out to be quite complicated.
None of the documentation I've seen covers the DrawingArea widget or its use
in much detail.  I've gathered that I have to create a pixmap onto which to
render the circle (using Gtk::Curve I suppose), but thus far I've not been
able to get the Gtk::Gdk::Pixmap::new procedure to work.  I've read through
the Gtk-Perl Tutorial and as much of the documentation at as I
could.  Are there other sources of documentation that I may have overlooked?



David P. Fannin 
Database Administrator                                  dpf umr edu 
UM-Rolla Computing and Information Services      FAX (573) 341-4216 
URL                   PHONE (573) 341-4841 

gtk-perl-list mailing list
gtk-perl-list gnome org

Dov Grobgeld                        | Email: dov orbotech com      /+  \  PCB
Algorithms Group Leader, Orbotech   | Phone: +972-8-9423882        \  +/  AOI
POB 215, Yavne 81102, Israel        | Fax:   +972-8-9423775       __| |
               Disclaimer: All views above are mine alone.        ____|

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]