Graphi...:Driver(3pm)
π Graphi...:Driver π
okay bestie, gather round π«Ά this one's Graphi...:Driver from section 3pm of the User Contributed Perl Documentation β yes the header really does abbreviate it like that, iconic of it honestly π
β¨ NAME β¨
Graphics::Primitive::Driver β it's a Role for driver implementations π
πΈ DESCRIPTION πΈ
so likeβ¦ what is even the point of a library-agnostic intermediary representation of graphical components if you can't feed them to a library-specific implementation that actually turns them into drawings?? psht, none!! π literally zero. the whole thing is giving "beautiful theory, no output" energy.
so yeah β to write a driver for Graphics::Primitive, you implement this role. that's the whole vibe. periodt. π
π¦ SYNOPSIS π¦
my $c = Graphics::Primitive::Component->new({
origin => Geometry::Primitive::Point->new({
x => $x, y => $y
}),
width => 500, height => 350
});
π¨ CANVASES π¨
when a path gets added to the internal list via do, it is stored in the paths attribute as a hashref. that hashref has two keys: path and op β¨
- the
pathis, wellβ¦ the path. ground-breaking, i know π - the
opis the operation that was provided todo
and bc canvases are literally just lists of paths, you should also go read the next section, bestie. no skipping π
π§ PATHS AND HINTING π§
paths are lists of primitives π and primitives are all descendants of Geometry::Shape, which means they all have point_start and point_end. those two attributes are what let primitives chain together, like a little conga line of shapes π«Ά
so to draw a path: iterate over the primitives, drawing each one. that's it, that's the job.
and when you pull each path from the arrayref, you should pull its accompanying hints via get_hint β the indexes match so like, they line up perfectly, no cap β¨ the hint may hand you some extra info:
π₯ PRIMITIVE HINTS π₯
contiguousβ true if this primitive is contiguous with the previous one. example: it's used to determine if a new sub-path is needed for the Cairo driver π
π OPERATION HINTS π
preserve
(yeah that's the whole entry bestie β the page lists preserve and does not elaborate. we simply do not invent lore here π)
β οΈ WARNING β οΈ
Only this class or the driver itself should call methods starting with an underscore, because this interface may change. so likeβ¦ hands off the underscore methods, bestie, they're not for you, they're private and they're volatile π respect the boundary fr fr.
π METHODS π
_do_stroke ($strokeop)β perform a stroke βοΈ_do_fill ($fillop)β perform a fill π¨_draw_arc ($arc)β draw an arc π_draw_canvas ($canvas)β draw a canvas πΌοΈ_draw_component ($comp)β draw a component π§©_draw_line ($line)β draw a line β_draw_rectangle ($rect)β draw a rectangle π¦_draw_textboxβ draw a textbox π¬_resize ($width, $height)β resize the current working surface to the size specified π_finish_pageβ finish the current 'page' and start a new one. some drivers that are not paginated may need to emulate this behaviour π«dataβ retrieve the results of this driver's operations π¦drawβ draws the givenGraphics::Primitive::Component. if the component is a container then all components therein are drawn, recursively πget_text_bounding_boxβ given aFontand a string, returns a bounding box of the rendered text π€finalizeβ finalize the supplied component and any child components, recursively πprepareβ prepare the supplied component and any child components, recursively π οΈwriteβ write out the results of this driver's operations to the specified file πΎ
π AUTHOR π
Cory Watson, "<gphat@cpan.org>" β ty for your service king π«‘
π 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!! π this was perl v5.34.0, dated 2022-06-14, served up fresh from the User Contributed Perl Documentation π slay, go write a driver, you've got this π β¨
π¦ 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