source: trunk/xgraph/jpgraph/Examples/textpalignex1.php

Last change on this file was 42, checked in by marrucho, 10 years ago
File size: 1.1 KB
Line 
1<?php // content="text/plain; charset=utf-8"
2require_once "jpgraph/jpgraph.php";
3require_once "jpgraph/jpgraph_canvas.php";
4
5// Caption below the image
6$txt="The day was rapidly becoming more and\nmore strange.\n\nNot only had he managed to\nget by the first pass without so much as\na hint of questions but now when he\ncould feel that the second pass wouldn't\nlong be noone had yet seen him.";
7
8$w=950;$h=250;
9$xm=20;$ym=20;
10$tw=300;
11
12$g = new CanvasGraph($w,$h);
13$img = $g->img;
14
15// Alignment for anchor points to use
16$palign = array('left','center','right');
17
18$n = count($palign);
19$t = new Text($txt);
20
21$y = $ym;
22for( $i=0; $i < $n; ++$i ) {
23
24    $x = $xm + $i*$tw;
25
26    $t->SetColor('black');
27    $t->SetAlign('left','top');
28    $t->SetFont(FF_ARIAL,FS_NORMAL,11);
29    $t->SetBox();
30    $t->SetParagraphAlign($palign[$i]);
31    $t->Stroke($img, $x,$y);
32
33    $img->SetColor('black');
34    $img->SetFont(FF_FONT1,FS_BOLD);
35    $img->SetTextAlign('center','top');
36    $img->StrokeText($x+140,$y+160,'"'.$palign[$i].'"'.' pargraph align');
37
38}
39
40// .. and send back to browser
41$g->Stroke();
42
43?>
44
Note: See TracBrowser for help on using the repository browser.