<?
#########################################################################################
# Croquis en ligne, pour réaliser la pancarte dans Pnyx #
# Auteur : Sébastien Tremblay, hide@address.com #
# #
# Pnyx - une application Web (PHP/MySQL) d'élections virtuelles conçue pour des élèves #
# du primaire et du secondaire, dans lequel ils sont amenés à faire des propositions #
# en ligne et voter pour leur favorite, sous la supervision d'un enseignant. #
# #
# Copyright (C) <2008 - 2009> #
# <Service national du RÉCIT de l'univers social de la Commission scolaire de la #
# Pointe-de-l'Île> #
# #
# This program is free software; you can redistribute it and/or modify it under the #
# terms of the GNU General Public License as published by the Free Software Foundation. #
# This program is distributed in the hope that it will be useful, but WITHOUT ANY #
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A #
# PARTICULAR PURPOSE. See the GNU General Public License for more details. #
# You should have received a copy of the GNU General Public License along with this #
# program as the file LICENSE.txt; if not, please see #
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. #
# #
# Service national du RÉCIT de l'univers social #
# http://www.recitus.qc.ca #
# Contact e-mail : steve-hide@address.com #
#########################################################################################
include_once(file_exists("constante.php")? "constante.php" : "../constante.php");
class CTextImage
{
var $m_ImageFinale;
var $m_Texte;
var $m_Police;
var $m_Taille;
var $m_CouleurR;
var $m_CouleurG;
var $m_CouleurB;
var $m_NomFichier;
function __construct($Texte, $Couleur, $Police = "Arial", $Bold = "", $Italic = "", $Taille = 16)
{
$this->m_Texte = $Texte;
$this->m_Police = strtolower($Police);
$this->m_Police .= ($Bold == "1") ? "B" : "";
$this->m_Police .= ($Italic == "1") ? "I" : "";
$this->m_Taille = substr($Taille, 0, strlen($Taille)-2);
$this->m_CouleurR = (hexdec(substr($Couleur,0,2)) < 32) ? 32 : hexdec(substr($Couleur,0,2));
$this->m_CouleurG = (hexdec(substr($Couleur,2,2)) < 32) ? 32 : hexdec(substr($Couleur,2,2));
$this->m_CouleurB = (hexdec(substr($Couleur,4,2)) < 32) ? 32 : hexdec(substr($Couleur,4,2));
$this->m_NomFichier = "image".time().md5(rand()).".gif";
$this->Demarrer();
}
function Demarrer()
{
$width = ((strlen($this->m_Texte) * (6*$this->m_Taille/6)) < 50) ? 50 : (strlen($this->m_Texte) * (6*$this->m_Taille/6));
$height = $this->m_Taille*2+10;
$this->m_ImageFinale = imagecreatetruecolor($width, $height);
$trans_color = imagecolorallocate($this->m_ImageFinale, 255, 0, 0);
$color = imagecolorallocate($this->m_ImageFinale, $this->m_CouleurR, $this->m_CouleurG, $this->m_CouleurB);
imagecolortransparent($this->m_ImageFinale, $trans_color);
$font = REP_ROOT.REP_POLICES.$this->m_Police.".ttf";
imagettftext($this->m_ImageFinale, $this->m_Taille, 0, 1, 20+$this->m_Taille, -$color, $font, $this->m_Texte);
imagegif($this->m_ImageFinale, REP_ROOT.REP_IMAGES_TMP.$this->m_NomFichier);
}
function ObtenirImage()
{
return REP_ROOT.REP_IMAGES_TMP.$this->m_NomFichier;
}
}
?>