source: branches/old/test/buttons/generate_images.php

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

Změněno: Přidání odkazu na správu účtů. Přesun odkazu Jak začít a registrace nahoru.
Opraveno: České nápisy na tlačítkách v hlavním panelu.
Odstraněno: Staré skripty z dob WoWEmu ze složky test.

File size: 2.8 KB
Line 
1<?php
2
3include('../global.php');
4
5function GenerateButton($Text = '', $Highlighted = 0)
6{
7 if($Highlighted == 1)
8 {
9 $Image3 = ImageCreateFromPNG("ButtonBright.png");
10 $Highlighted = '_b';
11 } else
12 {
13 $Image3 = ImageCreateFromPNG("Button.png");
14 $Highlighted = '';
15 }
16 $FileName = strtolower(strtr($Text, ' ', '_')).$Highlighted;
17 $FileName = StrTr($FileName, "áäèïéìëíòóöø¹»úùüý¾ÁÄÈÏÉÌËÍÒÓÖØ©«ÚÙÜÝ®", "aacdeeeinoorstuuuyzAACDEEEINOORSTUUUYZ"); // Odstranit diakritiku
18 $FileName = 'images/'.$FileName.'.png';
19 echo('Generuju '.$FileName.'<br>');
20
21 $Image = ImageCreate(imagesx($Image3) * 1.5, imagesy($Image3) * 1.5);
22 imagecopyresampled($Image, $Image3, 0, 0, 0, 0, imagesx($Image), imagesy($Image), imagesx($Image3), imagesy($Image3));
23 ImageDestroy($Image3);
24
25 $FontFile = 'FRIZQT__.ttf';
26 //$FontFile = 'c:\WINDOWS\fonts\arial.ttf';
27 $FontSize = 20;
28 $FontSizeShadow = $FontSize * 1.3;
29
30 $white = imagecolorallocate($Image, 255, 255, 255);
31 $grey = imagecolorallocate($Image, 200, 200, 200);
32 $black = imagecolorallocate($Image, 30, 30, 30);
33
34 $BoundBox = imagettfbbox($FontSizeShadow, 0, $FontFile, $Text);
35 $ShadowTextPositionY = imagesy($Image) / 2 + ($BoundBox[1] - $BoundBox[7]) / 2 - 2;
36 $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
37 $TextPositionY = imagesy($Image) / 2 + ($BoundBox[1] - $BoundBox[7]) / 2 - 2;
38 $SizeX = array();
39 for($I=0; $I<strlen($Text); $I++)
40 {
41 $BoundBox = imagettfbbox($FontSizeShadow, 0, $FontFile, $Text{$I});
42 $SizeX[$I] = ($BoundBox[2] - $BoundBox[0]);
43 }
44
45 $PositionX = imagesx($Image) / 2 - array_sum($SizeX) / 2;
46 for($I=0; $I<strlen($Text); $I++)
47 {
48 $PositionX += $SizeX[$I] / 2;
49 $BoundBox = imagettfbbox($FontSizeShadow, 0, $FontFile, $Text{$I});
50 $TextPositionX = $PositionX - ($BoundBox[2] - $BoundBox[0]) / 2;
51 ImageTTFText($Image, $FontSizeShadow, 0, $TextPositionX, $ShadowTextPositionY, $black, $FontFile, $Text{$I});
52 $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text{$I});
53 $TextPositionX = $PositionX - ($BoundBox[2] - $BoundBox[0]) / 2;
54 ImageTTFText($Image, $FontSize, 0, $TextPositionX, $TextPositionY, $grey, $FontFile, $Text{$I});
55 $PositionX += $SizeX[$I] / 2;
56 }
57 $Image2 = ImageCreateTrueColor(125, 27);
58 imagecopyresampled($Image2, $Image, 0, 0, 0, 0, imagesx($Image2), imagesy($Image2), imagesx($Image), imagesy($Image));
59
60 //header("Content-type: image/jpeg");
61 ImagePng($Image2, $FileName);
62 ImageDestroy($Image);
63 ImageDestroy($Image2);
64}
65
66$Texty = array('Úvod', 'Server', 'Dotace', 'Stahování', 'Jak zacít', 'Odkazy', 'Mapa', 'Guildy', 'Fórum', 'Registrace',
67 'Online hráci', 'Honor', 'Rasy', 'Povolání', 'Profese');
68foreach($Texty as $Item)
69{
70 GenerateButton($Item, 0);
71 GenerateButton($Item, 1);
72}
73?>
Note: See TracBrowser for help on using the repository browser.