Image::BoxModel::Lowlevel - Lowlevel functions for Image::BoxModel
For an example and general information see Image::BoxModel.pm
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.
($width, $height) = $image -> GetBoxSize (box => "name_of_your_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, # You can either specify a background color, then the box will be filled with that color background => [color] # or you can define a border color and a background color, then you will get a nice rectangle with border. # if you omit border_thickness it defaults to 1 background => [color], border_color => [color], border_thickness =>[color] );
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] );
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] );
$image -> BoxSplit ( box => "name_of_parent", orientation=> "[vertical|horizontal]", number => $number_of_little_boxes), );
Splits a box into "number" 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..
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)
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 );
$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.
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.
(documentation for myself rather than the user)
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);
Checks if verbose is on and then prints messages. $image -> print_message("Text");
Nothing. Please use the object oriented interface.
Nowhere at the moment.
Matthias Bloch, <lt>matthias at puffin ch<gt>
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.