Graphi...imitive(3pm)
β¨ NAME β¨
Graphics::Primitive β bestie, it's a device-and-library-agnostic graphic primitives situation π
Like, the manual page is literally called Graphi...imitive(3pm) (they truncated it, iconic of them) and it lives in the User Contributed Perl Documentation corner of the internet. Anyway. Let's get into it π
πΈ SYNOPSIS πΈ
okay so Graphics::Primitive is this whole device and library agnostic system for creating and manipulating various graphical elements β we're talking Borders, Fonts, Paths, and the like. Obsessed.
my $c = Graphics::Primitive::Component->new(
background_color => Graphics::Color::RGB->new(
red => 1, green => 0, blue => 0
),
width => 500, height => 350,
border => new Graphics::Primitive::Border->new( width => 5 )
);
my $driver = Graphics::Primitive::Driver::Cairo->new(format => 'SVG');
$driver->prepare($c);
$driver->finalize($c);
$driver->draw($c);
$driver->write($filename)
(yes the last line has no semicolon, no I will not be adding one, that's literally how it's written π)
π¦ DESCRIPTION π¦
Graphics::Primitive is a library agnostic system for drawing things.
The idea β and honestly the vibe β is to let you create and manipulate graphical components, and then pass them off to a Driver for the actual drawing part. You do the art direction, the Driver does the labor. Main character division of responsibility, fr fr π
π CONCEPTS π
The root object for Graphics::Primitive is the Component. Components contain all the common elements that you'd expect: margins, padding, background color etc. All the basics, all present.
The next most important is the Container. Containers are Components that can hold other Components. Containers have all the attributes and methods of a Component with the addition of the layout_manager attribute for us with Layout::Manager.
Another important Component is the Canvas. The Canvas differs from other components by being a container for various Geometry::Primitive objects. This allows drawing of arbitrary shapes that do not fit existing components. Slay, honestly π
π DRAWING LIFECYCLE π
After creating all your components, there is a lifecycle that allows them to do their internal housekeeping to prepare for eventual drawing. The lifecycle is: prepare, layout and pack. Detailed explanation of these methods can be found in Component.
not me calling it a "lifecycle" like it's a glow-up routine but honestly? it kind of is β¨
π«Ά PREPARATION π«Ά
Graphics::Primitive::Component has a "prepared" flag. This flag is set as part of the "prepare" method (shocking, I know). If this flag is set, then subsequent calls to "prepare" are ignored.
Containers also have a prepare flag, but this flag is not set when calling "prepare". A Container's flag should be set by the layout manager. More information may be found with Layout::Manager.
so like... a Container is not gonna prepare itself, bestie. somebody else has to. iykyk π
π§ INSPIRATION π§
Most of the concepts that you'll find in Graphics::Primitive are inspired by Cairo's API (<http://cairographics.org>) and CSS's box model (<http://www.w3.org/Style/CSS/>). The range. The taste. The references. πΈ
β AUTHOR β
Cory Watson, "<gphat@cpan.org>"
π CONTRIBUTORS π
- Florian Ragwitz
π ACKNOWLEDGEMENTS π
Many of the ideas here come from my experience using the Cairo library.
π₯ COPYRIGHT & LICENSE π₯
Copyright 2008-2010 by Cory G Watson.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page, bestie π¦ sign-off time: this was perl v5.34.0, dated 2022-06-14, and yes it's still filed under Graphi...imitive(3pm) because truncation is forever ππ mwah, go draw something iconic β¨
π¦ where this page comes from
- debian bookworm: libgraphics-primitive-perl 0.67-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libgraphics-primitive-perl 0.67-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libgraphics-primitive-perl 0.67-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libgraphics-primitive-perl 0.67-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libgraphics-primitive-perl 0.67-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms