source: branches/old/test/buttons/button.php_zaloha

Last change on this file was 123, checked in by george, 17 years ago

Přesun složky pro generování tlačítek do složky test.

File size: 2.1 KB
Line 
1<?
2include('code.php');
3
4if(array_key_exists('b', $_GET)) $Image3 = ImageCreateFromPNG("ButtonBright.png");
5else $Image3 = ImageCreateFromPNG("Button.png");
6
7$Image = ImageCreate(imagesx($Image3) * 1.5, imagesy($Image3) * 1.5);
8imagecopyresampled($Image, $Image3, 0, 0, 0, 0, imagesx($Image), imagesy($Image), imagesx($Image3), imagesy($Image3));
9ImageDestroy($Image3);
10
11if(array_key_exists('text', $_GET)) $Text = $_GET['text'];
12else $Text = 'None';
13
14$FontFile = 'FRIZQT__.TTF';
15//$FontFile = 'c:\WINDOWS\fonts\arial.ttf';
16$FontSize = 20;
17$FontSizeShadow = $FontSize * 1.3;
18
19$white = imagecolorallocate($Image, 255, 255, 255);
20$grey = imagecolorallocate($Image, 200, 200, 200);
21$black = imagecolorallocate($Image, 30, 30, 30);
22
23$BoundBox = imagettfbbox($FontSizeShadow, 0, $FontFile, $Text);
24$ShadowTextPositionY = imagesy($Image) / 2 + ($BoundBox[1] - $BoundBox[7]) / 2 - 2;
25$BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
26$TextPositionY = imagesy($Image) / 2 + ($BoundBox[1] - $BoundBox[7]) / 2 - 2;
27$SizeX = array();
28for($I=0;$I<strlen($Text);$I++)
29{
30 $BoundBox = imagettfbbox($FontSizeShadow, 0, $FontFile, $Text{$I});
31 $SizeX[$I] = ($BoundBox[2] - $BoundBox[0]);
32}
33
34$PositionX = imagesx($Image) / 2 - array_sum($SizeX) / 2;
35for($I=0; $I<strlen($Text); $I++)
36{
37 $PositionX += $SizeX[$I] / 2;
38 $BoundBox = imagettfbbox($FontSizeShadow, 0, $FontFile, $Text{$I});
39 $TextPositionX = $PositionX - ($BoundBox[2] - $BoundBox[0]) / 2;
40 ImageTTFText($Image, $FontSizeShadow, 0, $TextPositionX, $ShadowTextPositionY, $black, $FontFile, to_utf8($Text{$I}));
41 $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text{$I});
42 $TextPositionX = $PositionX - ($BoundBox[2] - $BoundBox[0]) / 2;
43 ImageTTFText($Image, $FontSize, 0, $TextPositionX, $TextPositionY, $grey, $FontFile, to_utf8($Text{$I}));
44 $PositionX += $SizeX[$I] / 2;
45}
46$Image2 = ImageCreateTrueColor(125, 27);
47imagecopyresampled($Image2, $Image, 0, 0, 0, 0, imagesx($Image2), imagesy($Image2), imagesx($Image), imagesy($Image));
48
49header("Content-type: image/jpeg");
50ImageJpeg($Image2);
51ImageDestroy($Image);
52ImageDestroy($Image2);
53?>
Note: See TracBrowser for help on using the repository browser.