The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Math::Geometry::Construction::Role::Output - graphical output issues

VERSION

Version 0.019

DESCRIPTION

This role provides attributes and methods that are common to all classes which actually draw something.

INTERFACE

Public Attributes

hidden

If set to a true value, the respective object does not create any drawing output.

style

Hash reference with style settings. You can get the reference using the style_hash accessor. However, the recommended way to set arguments after construction is to use the style accessor to access single entries of the hash. (For people familiar with Moose, this is the accessor method of the Hash trait.)

Example:

  $point->style(fill => 'red') if(!$point->style('fill'));

The valid keys and values depend on the output type. From the point of view of Math::Geometry::Construction, any defined strings for keys and values are allowed. For SVG output, the hash is handed over as a style hash to the respective element (see SVG). For TikZ output, the style settings are realized by raw_mod calls (see LaTeX::TikZ).

Labels

A label is a little piece of text next to an object. The default text anchor for the label is provided by the class consuming this role. The positioning of the label is a tricky task. For example, should the label of a point be printed left of right of the point, above or below etc.? - Ideally, wherever is most space left by lines and circles crossing that point. Obviously, the extension of the label's bounding box has to be taken into account.

So far, I have not come up with a very convincing concept for achieving this. At the moment, the label positions provided by the objects are very primitive. For example, for a point, it is just the position of the point itself. This looks very ugly and has to be corrected by setting label_offset_x and/or label_offset_y. In the future, these might be estimated if not set by the user. Also possibly, the user might be able to provide some kind of direction and the distance is calculated automatically. All I can say at the moment is that label positioning is prone to change and that currently, you will only get decently looking results if you set the offset values yourself.

label

Holds the label text. If not set nothing is drawn. If undef the empty string is drawn. Usually there will be no visible difference. However, to really disable label output, call the clear_label method instead of setting the label to undef.

label_offset_x

Offset in x direction.

label_offset_y

Offset in y direction.

label_style

Style settings for the label. The comments for the style attribute also apply here.

Methods

draw_label

Draws the label. Called by objects that have consumed this role.

AUTHOR

Lutz Gehlen, <perl at lutzgehlen.de>

LICENSE AND COPYRIGHT

Copyright 2011 Lutz Gehlen.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.