Graphi...imitive(3pm)

πŸ“¦
version 0.67 Β· 2 versions
  • 0.67 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.67 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ 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 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