Graphi...:Canvas(3pm)
π NAME π
Graphics::Primitive::Canvas β a component composed of paths β¨ (yes that's the whole name, she's a whole vibe, she's a canvas, she holds paths, periodt)
πΈ DESCRIPTION πΈ
Graphics::Primitive::Canvas is a component for drawing arbitrary things. Bestie, she holds Paths and Operations. That's it, that's the job. π
β¨ SYNOPSIS β¨
use Graphics::Primitive::Canvas;
my $canvas = Graphics::Primitive::Canvas->new;
$canvas->move_to($point); # or just $x, $y
$canvas->do($op);
π¦ DESCRIPTION π¦
Okay so the Canvas is a container for multiple Paths. She's got a path that is the operative path for all path-related methods. The way that works is: you can treat the Canvas as if it was a path, calling methods like line_to or move_to right on her. No cap. π
When you are ready to perform an operation on the path, call the do method with the operation you want to call as an argument. Drawing a line and stroking it would look like:
$canvas->move_to(0, 0);
$canvas->line_to(10, 10);
my $op = Graphics::Primitive::Operation::Stroke->new;
$stroke->brush->color(
Graphics::Color::RGB->new(red => 0, blue => 1, green => 1)
);
$canvas->do($op);
When you instantiate a Canvas a newly instantiated path resides in path. After you call do that current path is moved to the paths list and new path is placed in current_path. If you want to keep the path around you can call save before do then call restore to put a saved copy of the path back into path. π
π METHODS π
π Constructor
newβ Creates a new Graphics::Primitive::Canvas β¨
π Instance Methods
doβ Given an operation, pushes the current path onto the path stack.
FIXME: Example
pathβ The current path this canvas is using.path_countβ Count of paths inpaths.pathsβ Arrayref of hashrefs representing paths combined with their operations:
[
{
path => $path,
op => $op
},
]
restoreβ Replace the current path by popping the top path from the saved path list.saveβ Copy the current path and push it onto the stack of saved paths.saved_pathsβ List of saved paths. Add to the list withsaveand pop from it usingrestore.saved_path_countβ Count of paths saved insaved_paths.
π« AUTHOR π«
Cory Watson <gphat@cpan.org> π«Ά
π COPYRIGHT & LICENSE π
Copyright 2008-2010 by Cory G Watson.
You can redistribute and/or modify this code under the same terms as Perl itself. π
Okay bestie that's the whole page, mwah π β this was perl v5.34.0, dated 2022-06-14, and it's the Graphi...:Canvas(3pm) page, slay, 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