NAME
Image::BoxModel::Lowlevel - Lowlevel functions for Image::BoxModel
SYNOPSIS
For an example and general information see Image::BoxModel.pm
DESCRIPTION
Image::BoxModel::Lowlevel implements some basic functionality.
It does so by using the methods from Image::BoxModel::Backend::[LIBRARY]
There are more backends planned and more functionality for each backend. (backends, patches, wishes are very welcome - in this order ;-)
Image::BoxModel::Lowlevel can be used directly, which is considered painful sometimes. You need to specify the size of a box before you can put text on it, for example, while 'Annotate' (inherited from ::Text) easily inserts a box and puts text on it. On the other hand, ::Lowlevel gives you full control.
Methods:
GetBoxSize
($width, $height) = $image -> GetBoxSize (box => "name_of_your_box");
Box
If you don't specify 'resize => $name_of_box_to_be_resized', the standard-box 'free' is chosen.
$image -> Box (
position =>[left|right|top|bottom],
width=> $x,
height => $y,
name => $name_of_new_box
);
FloatBox
To position a free-floating box wherever you want. There is virtually no error-checking, so perhaps better keep your hands off. ;-)
$image -> FloatBox(
top =>$top,
bottom=>$bottom,
right=> $right,
left=> $top,
name=>"whatever_you_call_it",
background =>[color]
);
GetTextSize
Get the boundig size of (rotated) text. Very useful to find out how big boxes need to be. ($width, $height) = $image -> GetTextSize( text => "Your Text", textsize => [number], rotate => [in degrees, may be negative as well] );
BoxSplit
$image => BoxSplit (box => "name_of_parent", orientation=> "[vertical|horizontal]", count => $number_of_little_boxes);
Splits a box into "count" small boxes. This can be useful if you want to have spreadsheet-style segmentation.
Naming of little boxes: parent_[number, counting from 0]
In bitmap-land we only have integer-size-boxes. Therefore some boxes may be 1 pixel taller than others..
Example:
If the parent is "myBox", then the babies are named myBox_0, myBox_1, ...myBox_2635 (if you are crazy enough to have 2635 babies)
Text
For easy use: Better use 'Annotate' (inherited from ::Text) instead of 'Text'. Annotate reserves a box automatically while Text does not.
But of course, if you need / want full control, use 'Text'.
Put (rotated, antialized) text on a box. Takes a bunch of parameters, of which "text" and "textsize" are mandatory.
$image -> Text(
text => $text,
textsize => [number],
color=> "black",
font => [font-file]
rotate=> [in degrees, may be negative as well],
box => "free",
align => [Left|Center|Right]", #align is how multiline-text is aligned
position =>[Center #position is how text will be positioned inside its box
NorthWest|
North|
NorthEast|
West|
SoutEast|
South|
SouthWest|
West],
background=> [color] #rather for debugging
);
Save
$image -> Save($filename);
Save the image to file. There is no error-checking at the moment. You need to know yourself if your chosen library supports the desired file-type.
DrawRectangle
Rectangle without border:
$image -> DrawRectangle (top => $top, bottom => $bottom, right => $right, left => $left, color => "color");
Rectangle with border:
$image -> DrawRectangle (top => $top, bottom => $bottom, right => $right, left => $left, fill_color => "color", border_color => "color");
Draws a rectangle with the given sides. There are no rotated rectangles at the moment.
Internal methods:
(documentation for myself rather than the user)
rotation
To rotate a given point by any point. It takes the angle in degrees, which is very comfortable to me. If you want to rotate something, feel free to use it. :-)
($x, $y) = $image -> rotation($x, $y, $x_center, $y_center, $angle);
print_message
Checks if verbose is on and then prints messages. $image -> print_message("Text");
EXPORT
Nothing. Please use the object oriented interface.
SEE ALSO
Nowhere at the moment.
AUTHOR
Matthias Bloch, <lt>matthias at puffin ch<gt>
COPYRIGHT AND LICENSE
Copyright (C) 2008 by :m)
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.