drawing shapes with color



Would someone please show me how to draw a shape, say a rectangle or a
line  with some color on????? I would really appreciate it. I've been
trying to find my way around these and to no avail:

## IMAGE WORKING:
 $hbox->realize();
($pixmap,$mask)=Gtk2::Gdk::Pixmap->create_from_xpm($hbox->window,undef,"image.jpg");
$img = Gtk2::Image->new_from_pixmap($pixmap,$mask);
$vbox->pack_start($img,FALSE,FALSE,0);

## GARBAGE BG, white line
$pixmap = Gtk2::Gdk::Pixmap->new($hbox->window,100,100,-1);
$gc = $hbox->style->fg_gc('selected');
$pixmap->draw_line($gc,0,0,100,100);
$img2 = Gtk2::Image->new_from_pixmap($pixmap,undef);
$vbox->pack_start($img2,FALSE,FALSE,0);


## WORKING
$pixmap = Gtk2::Gdk::Pixmap->new(undef,100,100,-1);
$gc = $hbox->style->fg_gc('selected');
$pixmap->draw_rectangle($gc,TRUE,0,0,100,100);

## GARBAGE BG
$pixmap = Gtk2::Gdk::Pixmap->new(undef,100,100,-1);
$gc = $hbox->style->fg_gc('selected');
$pixmap->draw_line($gc,0,0,100,100);
$img = Gtk2::Image->new_from_pixmap($pixmap,undef);
$vbox->pack_start($img,FALSE,FALSE,0);




## EITHER GETTING BLACK RECT OR GARBAGE depending on the draw_ methods
my $pixmap = Gtk2::Gdk::Pixmap->new(undef,100,100,-1);
my $gc = Gtk2::Gdk::GC->new($pixmap);
my $c = Gtk2::Gdk::Color->new(65535,65535,65535);
my $c2 = Gtk2::Gdk::Color->new(32000,0,0);
$gc->set_background($c);
$gc->set_foreground($c2);
$pixmap->draw_rectangle($gc,TRUE,0,0,100,100);
$img = Gtk2::Image->new_from_pixmap($pixmap,undef);
$vbox->pack_start($img,FALSE,FALSE,0);



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