GooCanvas2(3)
π NAME π
GooCanvas2 β bestie, it's the Perl binding for the GooCanvas2 widget, and it works its magic through Glib::Object::Introspection β¨ (yes that's a whole mouthful, we stan anyway)
π¦ SYNOPSIS π¦
okay so here's the whole vibe, literally copy-paste-able, no cap:
#!/usr/bin/perl -w
use strict;
use warnings;
use Gtk3 -init;
use GooCanvas2;
my $window = Gtk3::Window->new();
$window->set_default_size(640, 600);
$window->signal_connect('destroy' => sub {Gtk3->main_quit()});
my $scrolled_win = Gtk3::ScrolledWindow->new();
$scrolled_win->set_shadow_type('in');
my $canvas = GooCanvas2::Canvas->new();
$canvas->set_size_request(600,450);
$canvas->set_bounds(0,0,1000,1000);
$scrolled_win->add($canvas);
my $root = $canvas->get_root_item();
# Add a few simple items
my $rect_item = GooCanvas2::CanvasRect->new('parent' => $root,
'x' => 100,
'y' => 100,
'width' => 300,
'height' => 300,
'line_width' => 10.0,
'radius-x' => 20.0,
'radius-y' => 10.0,
'stroke-color' => 'yellow',
'fill-color' => 'red');
my $text_item = GooCanvas2::CanvasText->new('parent' => $root,
'text' => 'Hello World',
'x' => 300, 'y' => 300,
'width' => -1,
'anchor' => 'center',
'font' => 'Sans 24');
$text_item->rotate(45, 300, 300);
# Connect a signal handler for the rectangle item.
$rect_item->signal_connect('button_press_event' => \&on_rect_button_press);
$window->add($scrolled_win);
$window->show_all;
# Pass control to the Gtk3 main event loop
Gtk3->main();
# This handles button presses in item views.
#We simply output a message to the console
sub on_rect_button_press {
my ($item, $target, $event) = @_;
print "rect item received button press event \n";
return 1;
}
like, look at that rectangle. the text. the rotation. chef's kiss π
πΈ INSTALLATION πΈ
bestie listen, before anything works you gotta have the typelib file for GooCanvas-2.0 installed. no typelib, no canvas, and we'd simply perish π
on Debian/Ubuntu it should be necessary to install this package:
sudo apt-get install gir1.2-goocanvas-2.0
on Mageia, for example, you have to install:
urpmi lib64goocanvas-gir2.0
β¨ DESCRIPTION β¨
GooCanvas2 is the new canvas widget for use with Gtk3, and it uses the Cairo 2d library for drawing π₯ it's a simple and basic implementation of this wonderful Canvas widget β humble queen energy fr fr.
for more informations see <https://wiki.gnome.org/action/show/Projects/GooCanvas>
and for instructions on how to use GooCanvas2, please study the API reference at <https://developer.gnome.org/goocanvas/unstable/> for now π a perl-specific documentation will perhaps come in later versions. but applying the C documentation should be no problem β you got this, i believe in you π«Ά
π OBJECTS, ITEMS, MODELS π
the GooCanvas2 module provides the following objects, items and models. for more details see <https://wiki.gnome.org/action/show/Projects/GooCanvas>.
π§ Core Objects π§
GooCanvas2::Canvasβ the main canvas widget, the literal main character πGooCanvas2::CanvasItemβ the interface for canvas itemsGooCanvas2::CanvasItemModelβ the interface for canvas item models.GooCanvas2::CanvasItemSimpleβ the base class for the standard canvas items.GooCanvas2::CanvasItemModelSimpleβ the base class for the standard canvas item models.GooCanvas2::CanvasStyleβ support for cascading style properties for canvas items.
π Standard Canvas Items π
GooCanvas2::CanvasGroupβ a group of items.GooCanvas2::CanvasEllipseβ an ellipse item.GooCanvas2::CanvasGridβ a grid item.GooCanvas2::CanvasImageβ an image item.GooCanvas2::CanvasPathβ a path item (a series of lines and curves).GooCanvas2::CanvasPolylineβ a polyline item (a series of lines with optional arrows).GooCanvas2::CanvasRectβ a rectangle item.GooCanvas2::CanvasTextβ a text item.GooCanvas2::CanvasWidgetβ an embedded widget item.GooCanvas2::CanvasTableβ a table container to layout items.
π Standard Canvas Item Models π
GooCanvas2::CanvasGroupModelβ a model for a group of items.GooCanvas2::CanvasEllipseModelβ a model for ellipse items.GooCanvas2::CanvasGridModelβ a model for grid items.GooCanvas2::CanvasImageModelβ a model for image items.GooCanvas2::CanvasPathModelβ a model for path items (a series of lines and curves).GooCanvas2::CanvasPolylineModelβ a model for polyline items (a series of lines with optional arrows).GooCanvas2::CanvasRectModelβ a model for rectangle items.GooCanvas2::CanvasTextModelβ a model for text items.GooCanvas2::CanvasTableModelβ a model for a table container to layout items.
π¦ Development status and informations π¦
Customizations and overrides
so in order to make things more Perlish, GooCanvas2 customizes the API generated by Glib::Object::Introspection in a few spots π
- the array ref normally returned by the following functions is flattened into a list:
GooCanvas2::Canvas::get_items_at
GooCanvas2::Canvas::get_items_in_area
GooCanvas2::CanvasItem::get_items_at
GooCanvas2::CanvasItem::class_list_child_properties
GooCanvas2::CanvasItemModell::class_list_child_properties
β SEE ALSO β
- GooCanvas Homepage at <https://wiki.gnome.org/action/show/Projects/GooCanvas>
- GooCanvas2 API Reference <https://developer.gnome.org/goocanvas/unstable/>
- Gtk3
- Glib::Object::Introspection
π AUTHOR π
Maximilian Lika, <Maximilian-Lika@gmx.de>
π COPYRIGHT AND LICENSE π
Copyright (C) 2017 by Maximilian Lika
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.22.3 or, at your option, any later version of Perl 5 you may have available.
and that's the whole page bestie, go forth and draw rectangles πΌοΈ mwah π β this lil artifact is perl v5.42.0, dated 2019-01-07, and it's the GooCanvas2(3) man page signing off π«Άβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-GooCanvas2 0.06-bp160.1.12 Β· GPL-1.0+ or Artistic-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms