The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

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] The thing is, this is in the stage of being implemented at the moment.

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. You need to specify the size of a box before you can put text on it, for example. This can lead to non-fitting text.

Better use the Modules

Image::BoxModel::Text for all things text

and

Image::BoxModel::Chart for charts.

The bad thing is, these modules are yet to be written. ;-)

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) = 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)

I use it primarily for ::Charts, where axis-annotations and bars etc. are put into their small boxes. This enables easy positioning of these elements, because the object knows the borders of its boxes. You can for example center an element inside its box, which is much easier than calculating the exact position.

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],
        fill=>          "black",                                #color of text, will be renamed soon
        font => "verdana",
        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

 $image -> DrawRectangle (top => $top, bottom => $bottom, right => $right, left => $left, 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);

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.