1package Graphics::Primitive; 2use Moose; 3 4our $VERSION = '0.67'; 5 6__PACKAGE__->meta->make_immutable; 7 8no Moose; 91; 10__END__ 11 12=head1 NAME 13 14Graphics::Primitive - Device and library agnostic graphic primitives 15 16=cut 17 18=head1 SYNOPSIS 19 20Graphics::Primitive is a device and library agnostic system for creating 21and manipulating various graphical elements such as Borders, Fonts, Paths 22and the like. 23 24 my $c = Graphics::Primitive::Component->new( 25 background_color => Graphics::Color::RGB->new( 26 red => 1, green => 0, blue => 0 27 ), 28 width => 500, height => 350, 29 border => new Graphics::Primitive::Border->new( width => 5 ) 30 ); 31 32 my $driver = Graphics::Primitive::Driver::Cairo->new(format => 'SVG'); 33 34 $driver->prepare($c); 35 $driver->finalize($c); 36 $driver->draw($c); 37 38 $driver->write($filename) 39 40=head1 DESCRIPTION 41 42Graphics::Primitive is library agnostic system for drawing things. 43 44The idea is to allow you to create and manipulate graphical components and 45then pass them off to a L<Driver|Graphics::Primitive::Driver> for actual 46drawing. 47 48=head1 CONCEPTS 49 50The root object for Graphics::Primitive is the 51L<Component|Graphics::Primitive::Component>. Components contain all the 52common elements that you'd expect: margins, padding, background color etc. 53 54The next most important is the L<Container|Graphics::Primitive::Container>. 55Containers are Components that can hold other Components. Containers have all 56the attributes and methods of a Component with the addition of the 57I<layout_manager> attribute for us with L<Layout::Manager>. 58 59Another important Component is the L<Canvas|Graphics::Primitive::Canvas>. 60The Canvas differs from other components by being a container for various 61L<Geometry::Primitive> objects. This allows drawing of arbitrary shapes 62that do not fit existing components. 63 64=head1 DRAWING LIFECYCLE 65 66After creating all your components, there is a lifecycle that allows them 67to do their internal housekeeping to prepare for eventual drawing. The 68lifecycle is: B<prepare>, B<layout> and B<pack>. Detailed explanation of 69these methods can be found in L<Component|Graphics::Primitive::Component>. 70 71=head1 PREPARATION 72 73Graphics::Primitive::Component has a C<prepared> flag. This flag is set as 74part of the C<prepare> method (shocking, I know). If this flag is set, then 75subsequent calls to C<prepare> are ignored. Containers also have a prepare 76flag, but this flag is B<not> set when calling C<prepare>. A Container's flag 77should be set by the layout manager. More information may be found with 78L<Layout::Manager>. 79 80=head1 INSPIRATION 81 82Most of the concepts that you'll find in Graphics::Primitive are inspired by 83L<Cairo|http://cairographics.org>'s API and 84L<CSS|http://www.w3.org/Style/CSS/>'s box model. 85 86=head1 AUTHOR 87 88Cory Watson, C<< <gphat@cpan.org> >> 89 90=head1 CONTRIBUTORS 91 92Florian Ragwitz 93 94=head1 ACKNOWLEDGEMENTS 95 96Many of the ideas here come from my experience using the Cairo library. 97 98=head1 COPYRIGHT & LICENSE 99 100Copyright 2008-2010 by Cory G Watson. 101 102This program is free software; you can redistribute it and/or modify it 103under the same terms as Perl itself. 104