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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="colorPicker/css/style.css" rel="stylesheet" type="text/css" />
<link href="colorPicker/css/reset.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="colorPicker/js/jquery-1.4.2.js"></script>
<script type="text/javascript" src="colorPicker/js/jquery.simple-color.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.fontColor').simpleColor({
cellWidth: 9,
cellHeight: 9,
border: '1px solid #333333',
buttonClass: 'button',
displayColorCode: false
});
$('.fontBg').simpleColor({
cellWidth: 9,
cellHeight: 9,
border: '1px solid #333333',
buttonClass: 'button',
displayColorCode: false
});
});
</script>
</head>
<body>
<form action="font_page.php" method="post" name="form" title="form" lang="fr">
<label for="sampleText">Votre texte :</label>
<input name="sampleText" type="text" size="20" value="sample text"/>
<label for="fontSize">Taille :</label>
<select name="fontSize" id="fontSize">
<option value="20" selected="selected">1</option>
<option value="25">2</option>
<option value="30">3</option>
<option value="40">4</option>
</select>
<label for="fontColor">Couleur texte :</label>
<input name="fontColor" class="fontColor" value="#ffffff"/>
<label for="fontBg">couleur fond :</label>
<input name="fontBg" class="fontBg" value="#000000"/>
<input name="submit" type="submit" value="Valider" />
</form>
<?php
/*si on a recus des infos du formulaire*/
if (isset($_POST['submit']))
{
$hex_bg_color = $_POST['fontBg'];
$hex_txt_color = $_POST['fontColor'];
$txt_size = $_POST['fontSize'];
$txt_sample = $_POST['sampleText'];
/*on crée et affiche l'image pour VTKS embroidery.ttf*/
$font_file='VTKS embroidery.ttf';
$nom_image='VTKS embroidery.png';
CreateImage($hex_bg_color,$hex_txt_color,$txt_size,$txt_sample,$font_file,$nom_image);
echo "<p><img src='".$nom_image."'></p>";
/*on crée et affiche l'image pour home sweet home outline.otf*/
$font_file='home sweet home outline.otf';
$nom_image='home sweet home outline.png';
CreateImage($hex_bg_color,$hex_txt_color,$txt_size,$txt_sample,$font_file,$nom_image);
echo "<p><img src='".$nom_image."'></p>";
}
?>
<?php
/*fonction de creation d'image*/
function CreateImage($hex_bg_color,$hex_txt_color,$txt_size,$txt_sample,$font_file,$nom_image)
{
//header("Content-type: image/png");
$x = 200;
$y = 50;
//$hex_bg_color = $_POST['fontBg'];
//$hex_txt_color = $_POST['fontColor'];
//$txt_size = $_POST['fontSize'];
$angle = '0';
$txt_x = '35';
$txt_y = '30';
//$font_file = 'fonts/CAC Pinafore.ttf';
//$txt_sample = 'Voici un texte !';
$image = imagecreatetruecolor($x,$y);
$red = hexdec(substr($hex_bg_color,1,2));
$green = hexdec(substr($hex_bg_color,3,2));
$blue = hexdec(substr($hex_bg_color,5,2));
$bg_color = imagecolorallocate($image,$red,$green,$blue);
imagefilledrectangle($image, 0, 0, $x, $y, $bg_color);
$rouge = hexdec(substr($hex_txt_color,1,2));
$vert = hexdec(substr($hex_txt_color,3,2));
$bleu = hexdec(substr($hex_txt_color,5,2));
$txt_color = imagecolorallocate($image,$rouge,$vert,$bleu);
putenv('GDFONTPATH='.realpath('.'));
imagettftext($image, $txt_size, $angle, $txt_x, $txt_y, $txt_color, $font_file, $txt_sample);
//imagepng($image);
imagepng($image,$nom_image);
imagedestroy($image);
}
?>
</body>
</html> |
Partager