(Defined in: jpgraph_canvtools.php : 375)
Class usage and Overview
YOu can use this class to convieniently draw a text on canvas. The text may have multiple lines wher each line is separated by a "\n" (newline) character.
The text may also be enclosed in a rounded (possibly filled) rectangle.
See also related classes:
CanvasGraph and CanvasScale
Class Methods
Specify paragraph alignment for the text
Argument | Default | Description |
$aParaAlign
| | Alignment |
Description:
Specify paragraph alignment for the text. Alignments can be:
$g = new CanvasGraph(550,450);
$scale = new CanvasScale($g);
$scale->Set(0,27,0,53);
//
$t = new CanvasRectangleText();
$t->SetFillColor('lightgreen');
$t->SetFontColor('navy');
$t->SetFont(FF_ARIAL,FS_NORMAL,16);
$t->ParagraphAlign('center');
$t->Set("First line\nSecond line",0.5,19,26,32);
$t->Stroke($g->img,$scale);
Specify position for text
Argument | Default | Description |
$xl
|
0
| Top left X |
$yt
|
0
| Top left Y |
$w
|
0
| Width |
$h
|
0
| Height |
Description:
Set position for text. All coordinates will be translaed according to the current scale used.
Specify the text and position
Argument | Default | Description |
$aTxt
| | Text |
$xl
| | Top left X |
$yt
| | Top left Y |
$w
|
0
| Width |
$h
|
0
| Height |
Description:
Specify the text and position. All coordinates will be translated using the specified scale when stroked.
$t->SetShadow('');
$t->SetFont(FF_ARIAL,FS_BOLD,18);
$t->Set('Family',1,1,8);
$t->Stroke($g->img,$scale);
Specify auto margin when no specific size is specified
Argument | Default | Description |
$aMargin
| | Margin in pixels |
Description:
Specify auto margin when no specific size is specified. This margin is used to add extra space around the text and the border around the text.
Set border color for rectangle
Argument | Default | Description |
$aColor
| | Border color |
Description:
Set border color for rectangle
See also:
$t->SetColor('navy');
Set radius for corners
Argument | Default | Description |
$aRad
|
5
| Radius in pixels |
Description:
Specify the radius for the rounded corners. Specifying the value as 0 will give normal square corners.
$t->SetCornerRadius(15);
Specify fill color for rectangle
Argument | Default | Description |
$aFillColor
| | Color |
Description:
Specify fill color for rectangle
$t->SetFillColor('#12A73C');
Specify font
Argument | Default | Description |
$FontFam
| | Font family |
$aFontStyle
| | Font style |
$aFontSize
|
12
| Font size |
Description:
Specify font
$t->SetFont(FF_ARIAL,FS_BOLD,24);
Specify text (font) color
Argument | Default | Description |
$aColor
| | Color specification |
Description:
Set color for text. Use SetColor() to specify border colro and SetFillColor() to set fill color.
See also:
$t->SetFontCOlor('black')
Specify position
Argument | Default | Description |
$xl
|
0
| Top left X |
$yt
|
0
| Top left Y |
$w
|
0
| Width |
$h
|
0
| Height |
Description:
Specify position. All coordinates will be transalted with the specified scale when stroked.
Add a drop shadow
Argument | Default | Description |
$aColor
|
'gray'
| Color of shadow |
$aWidth
|
3
| Width of shadow |
Description:
Add a drop shadow to the rounded reactangle surranding the text
$t->SetShadow(); // Use default values
Specify text string
Argument | Default | Description |
$aTxt
| | Textt |
Description:
Set text string to be displayed. The text string may have multiple lines separated by a newline character "\n"
$t->Set("This is a text!");
Stroke text to canvas
Argument | Default | Description |
$aImg
| | Image context |
$scale
| | Scale |
Description:
Stroke text to canvas
See also:
$t->Stroke($graph->img,$scale);
Draws a text paragraph inside a rounded, possibly filled, rectangle
Argument | Default | Description |
$aTxt
|
''
| Text |
$xl
|
0
| Top left X |
$yt
|
0
| Top left Y |
$w
|
0
| Width |
$h
|
0
| Height |
Description:
Draws a text paragraph inside a rounded, possible filled, rectangle.
$t = new CanvasRectangleText();
$t->SetFillColor('lightgreen');
$t->SetFontColor('navy');
$t->SetFont(FF_ARIAL,FS_NORMAL,16);
$t->Set("\n\n\n\n\n\n\n\n\n\n\nTTF Fonts",0.5,19,26,32);
$t->Stroke($g->img,$scale);