This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
phptsmadmin/includes/jpgraph/docs/chunkhtml/example_src/textpalignex1.html

87 lines
9.9 KiB
HTML
Raw Normal View History

2011-05-28 09:51:52 +00:00
<div style="font-weight: bold;margin-left:15px;">textpalignex1.php</div><link rel="stylesheet" href="../phphl.css" type="text/css"><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code"> </span><span class="hl-comment">//</span><span class="hl-comment"> content=&quot;text/plain; charset=utf-8&quot;</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">require_once</span><span class="hl-code"> </span><span class="hl-quotes">&quot;</span><span class="hl-string">jpgraph/jpgraph.php</span><span class="hl-quotes">&quot;</span><span class="hl-code">;
</span><span class="hl-reserved">require_once</span><span class="hl-code"> </span><span class="hl-quotes">&quot;</span><span class="hl-string">jpgraph/jpgraph_canvas.php</span><span class="hl-quotes">&quot;</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Caption below the image</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$txt</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">The day was rapidly becoming more and</span><span class="hl-special">\n</span><span class="hl-string">more strange.</span><span class="hl-special">\n</span><span class="hl-special">\n</span><span class="hl-string">Not only had he managed to</span><span class="hl-special">\n</span><span class="hl-string">get by the first pass without so much as</span><span class="hl-special">\n</span><span class="hl-string">a hint of questions but now when he</span><span class="hl-special">\n</span><span class="hl-string">could feel that the second pass wouldn't</span><span class="hl-special">\n</span><span class="hl-string">long be noone had yet seen him.</span><span class="hl-quotes">&quot;</span><span class="hl-code">;
</span><span class="hl-var">$w</span><span class="hl-code">=</span><span class="hl-number">950</span><span class="hl-code">;</span><span class="hl-var">$h</span><span class="hl-code">=</span><span class="hl-number">250</span><span class="hl-code">;
</span><span class="hl-var">$xm</span><span class="hl-code">=</span><span class="hl-number">20</span><span class="hl-code">;</span><span class="hl-var">$ym</span><span class="hl-code">=</span><span class="hl-number">20</span><span class="hl-code">;
</span><span class="hl-var">$tw</span><span class="hl-code">=</span><span class="hl-number">300</span><span class="hl-code">;
</span><span class="hl-var">$g</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">CanvasGraph</span><span class="hl-brackets">(</span><span class="hl-var">$w</span><span class="hl-code">,</span><span class="hl-var">$h</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$img</span><span class="hl-code"> = </span><span class="hl-var">$g</span><span class="hl-code">-&gt;</span><span class="hl-identifier">img</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Alignment for anchor points to use</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$palign</span><span class="hl-code"> = </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">left</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">center</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">right</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$n</span><span class="hl-code"> = </span><span class="hl-identifier">count</span><span class="hl-brackets">(</span><span class="hl-var">$palign</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$t</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">Text</span><span class="hl-brackets">(</span><span class="hl-var">$txt</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$y</span><span class="hl-code"> = </span><span class="hl-var">$ym</span><span class="hl-code">;
</span><span class="hl-reserved">for</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-var">$i</span><span class="hl-code">=</span><span class="hl-number">0</span><span class="hl-code">; </span><span class="hl-var">$i</span><span class="hl-code"> &lt; </span><span class="hl-var">$n</span><span class="hl-code">; ++</span><span class="hl-var">$i</span><span class="hl-code"> </span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code">
</span><span class="hl-var">$x</span><span class="hl-code"> = </span><span class="hl-var">$xm</span><span class="hl-code"> + </span><span class="hl-var">$i</span><span class="hl-code">*</span><span class="hl-var">$tw</span><span class="hl-code">;
</span><span class="hl-var">$t</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetColor</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">black</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$t</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetAlign</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">left</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">top</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$t</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetFont</span><span class="hl-brackets">(</span><span class="hl-identifier">FF_ARIAL</span><span class="hl-code">,</span><span class="hl-identifier">FS_NORMAL</span><span class="hl-code">,</span><span class="hl-number">11</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$t</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetBox</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$t</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetParagraphAlign</span><span class="hl-brackets">(</span><span class="hl-var">$palign</span><span class="hl-brackets">[</span><span class="hl-var">$i</span><span class="hl-brackets">]</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$t</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-var">$img</span><span class="hl-code">, </span><span class="hl-var">$x</span><span class="hl-code">,</span><span class="hl-var">$y</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$img</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetColor</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">black</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$img</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetFont</span><span class="hl-brackets">(</span><span class="hl-identifier">FF_FONT1</span><span class="hl-code">,</span><span class="hl-identifier">FS_BOLD</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$img</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetTextAlign</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">center</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">top</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$img</span><span class="hl-code">-&gt;</span><span class="hl-identifier">StrokeText</span><span class="hl-brackets">(</span><span class="hl-var">$x</span><span class="hl-code">+</span><span class="hl-number">140</span><span class="hl-code">,</span><span class="hl-var">$y</span><span class="hl-code">+</span><span class="hl-number">160</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">&quot;</span><span class="hl-quotes">'</span><span class="hl-code">.</span><span class="hl-var">$palign</span><span class="hl-brackets">[</span><span class="hl-var">$i</span><span class="hl-brackets">]</span><span class="hl-code">.</span><span class="hl-quotes">'</span><span class="hl-string">&quot;</span><span class="hl-quotes">'</span><span class="hl-code">.</span><span class="hl-quotes">'</span><span class="hl-string"> pargraph align</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-brackets">}</span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> .. and send back to browser</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$g</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div>