Accueil > > > LIBRAIRIE GRAPHIQUE POUR GÉRER UN DESSIN AVEC FORMES (PHP5, CLASSE, HÉRITAGE, POLYMORPHISME)
LIBRAIRIE GRAPHIQUE POUR GÉRER UN DESSIN AVEC FORMES (PHP5, CLASSE, HÉRITAGE, POLYMORPHISME)
Information sur la source
Description
Voici un code qui permet de gérer facilement des formes sur un dessin. Le rendu est peut-etre basique, mais vous pouvez regarder le contenu du code. Il contient des classes avec des héritages ainsi que du polymorphisme écrit en php5. Son utilisation peut-etre utile pour de la génération automatique d'image... à vous de voir. Vous pouvez aussi essayer d'apprendre avec ce code ;)
Source
- <?php
- //////////////////////////////////////////////////////////////////////
- // FDraw.php
- //--------------------------------------------------------------------
- //
- // Classes for Drawing Objects
- //
- //--------------------------------------------------------------------
- // Revision History
- // V1.00 16 jun 2004 Jean-Sebastien Goupil
- //--------------------------------------------------------------------
- // (c) Jean-Sebastien Goupil
- // http://www.lookstrike.com
- //--------------------------------------------------------------------
- //////////////////////////////////////////////////////////////////////
-
- define("DEBUG",0);
- define("IMG_FORMAT_PNG", 1);
- define("IMG_FORMAT_JPEG", 2);
- define("IMG_FORMAT_WBMP", 4);
- define("IMG_FORMAT_GIF", 8);
-
- //////////////////////////////////////////////////////////////////////
- // Function: DebugTool()
- //////////////////////////////////////////////////////////////////////
- //
- // Explanation: If DEBUG == 1, this will print the argument
- // $text when calling the function.
- //
- //////////////////////////////////////////////////////////////////////
- function DebugTool($text) {
- if(constant("DEBUG")==1) {
- echo $text."<br>\n";
- }
- }
-
- //////////////////////////////////////////////////////////////////////
- // Class: FColor
- //////////////////////////////////////////////////////////////////////
- //
- // Explanation: Holds Color in RGB Format.
- //
- // Function FColor(): Save RGB value into the classes
- // Function allocate(): Return the int value for PHP color
- // Function r(): Return Red Color
- // Function g(): Return Green Color
- // Function b(): Return Blue Color
- //
- //////////////////////////////////////////////////////////////////////
- class FColor {
- protected $r,$g,$b; // int Hexadecimal Value
-
- public function FColor($r,$g,$b){
- $this->r = $r;
- $this->g = $g;
- $this->b = $b;
- DebugTool("*** FColor Created");
- }
- public function r(){
- return $this->r;
- }
- public function g(){
- return $this->g;
- }
- public function b(){
- return $this->b;
- }
- public function allocate($im) {
- DebugTool("* Color ".$this->r.".".$this->g.".".$this->b);
- return imagecolorallocate($im,$this->r,$this->g,$this->b);
- }
- };
-
- //////////////////////////////////////////////////////////////////////
- // Class: FPoint
- //////////////////////////////////////////////////////////////////////
- //
- // Explanation: Holds Position of object in 2d-Space.
- //
- // Function FPoint(): Save Position (x,y)
- //
- //////////////////////////////////////////////////////////////////////
- class FPoint {
- protected $x, $y; // int
-
- public function FPoint($x,$y){
- $this->x = $x;
- $this->y = $y;
- }
- };
-
-
- //////////////////////////////////////////////////////////////////////
- // Class: Form
- //////////////////////////////////////////////////////////////////////
- //
- // Explanation: Abstract Class, holds all forms that can be
- // drawn in PHP.
- //
- // Function Form(): Save Position (x,y), Color (color1,color2)
- // Function x(): Return X Position
- // Function y(): Return Y Position
- // Function w(): Return Width (if existing)
- // Function h(): Return Height (if existing)
- // Function draw(): Polymorphism
- // By calling this function, you draw the right
- // form held into Form Class.
- //
- //////////////////////////////////////////////////////////////////////
- class Form extends FPoint {
- protected $color1, $color2; // Fcolor
-
- public function Form($x,$y,Fcolor $color1,Fcolor $color2) {
- FPoint::FPoint($x,$y);
- $this->color1 = $color1;
- $this->color2 = $color2;
- DebugTool("*** Form Created");
- }
- public function x() {
- return $this->x;
- }
- public function y() {
- return $this->y;
- }
- public function w() {
- return $this->w;
- }
- public function h() {
- return $this->h;
- }
- };
-
- //////////////////////////////////////////////////////////////////////
- // Class: FRectangle
- //////////////////////////////////////////////////////////////////////
- //
- // Explanation: Rectangle Object
- // * color1 and color2 aren't null
- // Border (color1), Filled (color2)
- // * color1 null, color2 not null
- // Border (none), Filled (color2)
- // * color1 not null, color2 null
- // Border (color1), Filled (none)
- //
- // Function FRectangle():Save Position (x,y), Size (w,h), Color (color1,color2)
- // Function draw(): Draw Rectangle on $im
- //
- //////////////////////////////////////////////////////////////////////
- class FRectangle extends Form {
- protected $w, $h; // int
-
- public function FRectangle($x,$y,$w,$h,Fcolor $color1,Fcolor $color2) {
- Form::Form($x,$y,$color1,$color2);
- $this->w = $w;
- $this->h = $h;
- DebugTool("*** FRectangle Created");
- }
- public function draw($im) {
- $color_foreground = (is_null($this->color1))?NULL:$this->color1->allocate($im);
- $color_background = (is_null($this->color2))?NULL:$this->color2->allocate($im);
- if(!is_null($color_background))
- imagefilledrectangle($im,$this->x,$this->y,$this->x+$this->w,$this->y+$this->h,$color_background);
- if(!is_null($color_foreground))
- imagerectangle($im,$this->x,$this->y,$this->x+$this->w,$this->y+$this->h,$color_foreground);
- }
- };
-
- //////////////////////////////////////////////////////////////////////
- // Class: FSquare
- //////////////////////////////////////////////////////////////////////
- //
- // Explanation: Child of FRectangle. Same Explanation and Functions.
- // Size (c) -> Side
- //
- //////////////////////////////////////////////////////////////////////
- class FSquare extends FRectangle {
- public function FSquare($x,$y,$c,Fcolor $color1,Fcolor $color2) {
- FRectangle::FRectangle($x,$y,$c,$c,$color1,$color2);
- DebugTool("*** FSquare Created");
- }
- };
-
- //////////////////////////////////////////////////////////////////////
- // Class: FEllipse
- //////////////////////////////////////////////////////////////////////
- //
- // Explanation: Ellipse Object
- // * color1 and color2 aren't null
- // Border (color1), Filled (color2)
- // * color1 null, color2 not null
- // Border (none), Filled (color2)
- // * color1 not null, color2 null
- // Border (color1), Filled (none)
- //
- // Function FEllipse(): Save Position (x,y), Size (w,h), Color (color1,color2)
- // Function draw(): Draw Ellipse on $im
- //
- //////////////////////////////////////////////////////////////////////
- class FEllipse extends Form {
- protected $w, $h; // int
-
- public function FEllipse($x,$y,$w,$h,Fcolor $color1,Fcolor $color2) {
- Form::Form($x,$y,$color1,$color2);
- $this->w = $w;
- $this->h = $h;
- DebugTool("*** FEllipse Created");
- }
- public function draw($im) {
- $color_foreground = (is_null($this->color1))?NULL:$this->color1->allocate($im);
- $color_background = (is_null($this->color2))?NULL:$this->color2->allocate($im);
- if(!is_null($color_background))
- imagefilledellipse($im,$this->x,$this->y,$this->w,$this->h,$color_background);
- if(!is_null($color_foreground))
- imageellipse($im,$this->x,$this->y,$this->w,$this->h,$color_foreground);
- }
- };
-
- //////////////////////////////////////////////////////////////////////
- // Class: FCircle
- //////////////////////////////////////////////////////////////////////
- //
- // Explanation: Child of FEllipse. Same Explanation and Functions.
- // Size (r) -> Radius
- //
- //////////////////////////////////////////////////////////////////////
- class FCircle extends FEllipse {
- public function FCircle($x,$y,$r,FColor $color1,FColor $color2) {
- FEllipse::FEllipse($x,$y,$r,$r,$color1,$color2);
- DebugTool("*** FCircle Created");
- }
- };
-
- //////////////////////////////////////////////////////////////////////
- // Class: FVector
- //////////////////////////////////////////////////////////////////////
- //
- // Explanation: Vector Object (Line)
- // * color1 and color2 aren't null
- // Dashed Line of color1 and color2
- // * color1 not null, color2 null
- // Continuous Line
- //
- // Function FVector(): Save Position (x,y), Size (w,h), Color (color1,color2)
- // Function draw(): Draw Vector on $im
- //
- // ** WARNING **
- // w and h is the width and height of the line, x and y being start point
- // The x2, and y2 are respectively x+w and y+h
- //
- //////////////////////////////////////////////////////////////////////
- class FVector extends Form { // a vector is a flatten form
- protected $w, $h; // int
-
- public function fVector($x,$y,$w,$h,Fcolor $color1,Fcolor $color2) {
- Form::Form($x,$y,$color1,$color2);
- $this->w = $w;
- $this->h = $h;
- DebugTool("*** FVector Created");
- }
- public function draw($im) {
- $color1 = (is_null($this->color1))?NULL:$this->color1->allocate($im);
- $color2 = (is_null($this->color2))?NULL:$this->color2->allocate($im);
- if(!is_null($color1) && !is_null($color2)){
- $style = array($color1,$color1,$color1,$color1,$color1,$color2,$color2,$color2,$color2,$color2);
- imagesetstyle($im, $style);
- imageline($im,$this->x,$this->y,$this->x+$this->w,$this->y+$this->h,IMG_COLOR_STYLED);
- }
- elseif(!is_null($color1))
- imageline($im,$this->x,$this->y,$this->x+$this->w,$this->y+$this->h,$color1);
- }
- };
-
- //////////////////////////////////////////////////////////////////////
- // Class: FText
- //////////////////////////////////////////////////////////////////////
- //
- // Explanation: Holds Text
- // * font: int 1 to 5 (inclusively)
- // * horiz: boolean (true=horizontal, false=vertical)
- //
- // Function FText(): Save Position (x,y), Text (text), Font (font), Direction (horiz), Color (color)
- // Function draw(): Draw Text on $im
- //
- //////////////////////////////////////////////////////////////////////
- class FText extends FPoint {
- private $text; // char *
- private $color; // Fcolor
- private $font; // int
- private $horiz; // bool
-
- public function FText($x,$y,$text,$font,$horiz,FColor $color){
- FPoint::FPoint($x,$y);
- $this->text = $text;
- $this->color = $color;
- $this->font = $font;
- $this->horiz = $horiz;
- DebugTool("*** FText Created");
- }
- public function draw($im) {
- $color = (is_null($this->color))?NULL:$this->color->allocate($im);
- if(!is_null($color))
- if($this->horiz==true)
- imagestring($im,$this->font,$this->x,$this->y,$this->text,$color);
- else
- imagestringup($im,$this->font,$this->x,$this->y,$this->text,$color);
- }
- };
-
- //////////////////////////////////////////////////////////////////////
- // Class: FDrawing
- //////////////////////////////////////////////////////////////////////
- //
- // Explanation: Holds the drawing $im and can also holds all forms and texts
- // * You must call init().
- // * You can use get_im() to add other kind of form not
- // held into these classes.
- //
- // Function FDrawing(): Size (w,h), Filename (filename), BackGround Color (color)
- // Function init(): Init Image and color background
- // Function get_im(): Return $im
- // Function add_form(): Add form into the form array (for future drawing)
- // Function add_text(): Add text into the text array (for future drawing)
- // Function draw_all(): Draw first all forms and after all texts on $im
- // Function finish(): Save $im into the file (many format available)
- // Function destroy(): Free the memory of PHP (called also by destructor)
- //
- //////////////////////////////////////////////////////////////////////
- class FDrawing {
- private $w, $h; // int
- private $color; // Fcolor
- private $filename; // char *
- private $im; // {object}
- private $form = array();// Form *
- private $text = array();// Ftext *
-
- public function FDrawing($w,$h,$filename,Fcolor $color) {
- $this->w = $w;
- $this->h = $h;
- $this->filename = $filename;
- $this->color = $color;
- DebugTool("*** FDrawing Created");
- }
- function __destruct() {
- $this->destroy();
- }
- public function init(){
- $this->im = imagecreate($this->w, $this->h)
- or die("Can't Initialize the GD Libraty");
- imagecolorallocate($this->im,$this->color->r(),$this->color->g(),$this->color->b());
- }
- public function get_im(){
- return $this->im;
- }
- public function add_form(Form $form){
- $this->form[] = $form;
- }
- public function add_text(Ftext $text){
- $this->text[] = $text;
- }
- public function draw_all(){
- for($i=0;$i<count($this->form);$i++)
- $this->form[$i]->draw($this->im);
- for($i=0;$i<count($this->text);$i++)
- $this->text[$i]->draw($this->im);
- }
- public function finish($image_style=IMG_FORMAT_PNG,$quality=100){
- if($image_style==constant("IMG_FORMAT_PNG"))
- imagepng($this->im,$this->filename);
- elseif($image_style==constant("IMG_FORMAT_JPEG"))
- imagejpeg($this->im,$this->filename,$quality);
- elseif($image_style==constant("IMG_FORMAT_WBMP"))
- imagewbmp($this->im,$this->filename);
- elseif($image_style==constant("IMG_FORMAT_GIF"))
- imagegif($this->im,$this->filename);
- }
- public function destroy(){
- imagedestroy($this->im);
- }
- };
- ?>
<?php
//////////////////////////////////////////////////////////////////////
// FDraw.php
//--------------------------------------------------------------------
//
// Classes for Drawing Objects
//
//--------------------------------------------------------------------
// Revision History
// V1.00 16 jun 2004 Jean-Sebastien Goupil
//--------------------------------------------------------------------
// (c) Jean-Sebastien Goupil
// http://www.lookstrike.com
//--------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////
define("DEBUG",0);
define("IMG_FORMAT_PNG", 1);
define("IMG_FORMAT_JPEG", 2);
define("IMG_FORMAT_WBMP", 4);
define("IMG_FORMAT_GIF", 8);
//////////////////////////////////////////////////////////////////////
// Function: DebugTool()
//////////////////////////////////////////////////////////////////////
//
// Explanation: If DEBUG == 1, this will print the argument
// $text when calling the function.
//
//////////////////////////////////////////////////////////////////////
function DebugTool($text) {
if(constant("DEBUG")==1) {
echo $text."<br>\n";
}
}
//////////////////////////////////////////////////////////////////////
// Class: FColor
//////////////////////////////////////////////////////////////////////
//
// Explanation: Holds Color in RGB Format.
//
// Function FColor(): Save RGB value into the classes
// Function allocate(): Return the int value for PHP color
// Function r(): Return Red Color
// Function g(): Return Green Color
// Function b(): Return Blue Color
//
//////////////////////////////////////////////////////////////////////
class FColor {
protected $r,$g,$b; // int Hexadecimal Value
public function FColor($r,$g,$b){
$this->r = $r;
$this->g = $g;
$this->b = $b;
DebugTool("*** FColor Created");
}
public function r(){
return $this->r;
}
public function g(){
return $this->g;
}
public function b(){
return $this->b;
}
public function allocate($im) {
DebugTool("* Color ".$this->r.".".$this->g.".".$this->b);
return imagecolorallocate($im,$this->r,$this->g,$this->b);
}
};
//////////////////////////////////////////////////////////////////////
// Class: FPoint
//////////////////////////////////////////////////////////////////////
//
// Explanation: Holds Position of object in 2d-Space.
//
// Function FPoint(): Save Position (x,y)
//
//////////////////////////////////////////////////////////////////////
class FPoint {
protected $x, $y; // int
public function FPoint($x,$y){
$this->x = $x;
$this->y = $y;
}
};
//////////////////////////////////////////////////////////////////////
// Class: Form
//////////////////////////////////////////////////////////////////////
//
// Explanation: Abstract Class, holds all forms that can be
// drawn in PHP.
//
// Function Form(): Save Position (x,y), Color (color1,color2)
// Function x(): Return X Position
// Function y(): Return Y Position
// Function w(): Return Width (if existing)
// Function h(): Return Height (if existing)
// Function draw(): Polymorphism
// By calling this function, you draw the right
// form held into Form Class.
//
//////////////////////////////////////////////////////////////////////
class Form extends FPoint {
protected $color1, $color2; // Fcolor
public function Form($x,$y,Fcolor $color1,Fcolor $color2) {
FPoint::FPoint($x,$y);
$this->color1 = $color1;
$this->color2 = $color2;
DebugTool("*** Form Created");
}
public function x() {
return $this->x;
}
public function y() {
return $this->y;
}
public function w() {
return $this->w;
}
public function h() {
return $this->h;
}
};
//////////////////////////////////////////////////////////////////////
// Class: FRectangle
//////////////////////////////////////////////////////////////////////
//
// Explanation: Rectangle Object
// * color1 and color2 aren't null
// Border (color1), Filled (color2)
// * color1 null, color2 not null
// Border (none), Filled (color2)
// * color1 not null, color2 null
// Border (color1), Filled (none)
//
// Function FRectangle():Save Position (x,y), Size (w,h), Color (color1,color2)
// Function draw(): Draw Rectangle on $im
//
//////////////////////////////////////////////////////////////////////
class FRectangle extends Form {
protected $w, $h; // int
public function FRectangle($x,$y,$w,$h,Fcolor $color1,Fcolor $color2) {
Form::Form($x,$y,$color1,$color2);
$this->w = $w;
$this->h = $h;
DebugTool("*** FRectangle Created");
}
public function draw($im) {
$color_foreground = (is_null($this->color1))?NULL:$this->color1->allocate($im);
$color_background = (is_null($this->color2))?NULL:$this->color2->allocate($im);
if(!is_null($color_background))
imagefilledrectangle($im,$this->x,$this->y,$this->x+$this->w,$this->y+$this->h,$color_background);
if(!is_null($color_foreground))
imagerectangle($im,$this->x,$this->y,$this->x+$this->w,$this->y+$this->h,$color_foreground);
}
};
//////////////////////////////////////////////////////////////////////
// Class: FSquare
//////////////////////////////////////////////////////////////////////
//
// Explanation: Child of FRectangle. Same Explanation and Functions.
// Size (c) -> Side
//
//////////////////////////////////////////////////////////////////////
class FSquare extends FRectangle {
public function FSquare($x,$y,$c,Fcolor $color1,Fcolor $color2) {
FRectangle::FRectangle($x,$y,$c,$c,$color1,$color2);
DebugTool("*** FSquare Created");
}
};
//////////////////////////////////////////////////////////////////////
// Class: FEllipse
//////////////////////////////////////////////////////////////////////
//
// Explanation: Ellipse Object
// * color1 and color2 aren't null
// Border (color1), Filled (color2)
// * color1 null, color2 not null
// Border (none), Filled (color2)
// * color1 not null, color2 null
// Border (color1), Filled (none)
//
// Function FEllipse(): Save Position (x,y), Size (w,h), Color (color1,color2)
// Function draw(): Draw Ellipse on $im
//
//////////////////////////////////////////////////////////////////////
class FEllipse extends Form {
protected $w, $h; // int
public function FEllipse($x,$y,$w,$h,Fcolor $color1,Fcolor $color2) {
Form::Form($x,$y,$color1,$color2);
$this->w = $w;
$this->h = $h;
DebugTool("*** FEllipse Created");
}
public function draw($im) {
$color_foreground = (is_null($this->color1))?NULL:$this->color1->allocate($im);
$color_background = (is_null($this->color2))?NULL:$this->color2->allocate($im);
if(!is_null($color_background))
imagefilledellipse($im,$this->x,$this->y,$this->w,$this->h,$color_background);
if(!is_null($color_foreground))
imageellipse($im,$this->x,$this->y,$this->w,$this->h,$color_foreground);
}
};
//////////////////////////////////////////////////////////////////////
// Class: FCircle
//////////////////////////////////////////////////////////////////////
//
// Explanation: Child of FEllipse. Same Explanation and Functions.
// Size (r) -> Radius
//
//////////////////////////////////////////////////////////////////////
class FCircle extends FEllipse {
public function FCircle($x,$y,$r,FColor $color1,FColor $color2) {
FEllipse::FEllipse($x,$y,$r,$r,$color1,$color2);
DebugTool("*** FCircle Created");
}
};
//////////////////////////////////////////////////////////////////////
// Class: FVector
//////////////////////////////////////////////////////////////////////
//
// Explanation: Vector Object (Line)
// * color1 and color2 aren't null
// Dashed Line of color1 and color2
// * color1 not null, color2 null
// Continuous Line
//
// Function FVector(): Save Position (x,y), Size (w,h), Color (color1,color2)
// Function draw(): Draw Vector on $im
//
// ** WARNING **
// w and h is the width and height of the line, x and y being start point
// The x2, and y2 are respectively x+w and y+h
//
//////////////////////////////////////////////////////////////////////
class FVector extends Form { // a vector is a flatten form
protected $w, $h; // int
public function fVector($x,$y,$w,$h,Fcolor $color1,Fcolor $color2) {
Form::Form($x,$y,$color1,$color2);
$this->w = $w;
$this->h = $h;
DebugTool("*** FVector Created");
}
public function draw($im) {
$color1 = (is_null($this->color1))?NULL:$this->color1->allocate($im);
$color2 = (is_null($this->color2))?NULL:$this->color2->allocate($im);
if(!is_null($color1) && !is_null($color2)){
$style = array($color1,$color1,$color1,$color1,$color1,$color2,$color2,$color2,$color2,$color2);
imagesetstyle($im, $style);
imageline($im,$this->x,$this->y,$this->x+$this->w,$this->y+$this->h,IMG_COLOR_STYLED);
}
elseif(!is_null($color1))
imageline($im,$this->x,$this->y,$this->x+$this->w,$this->y+$this->h,$color1);
}
};
//////////////////////////////////////////////////////////////////////
// Class: FText
//////////////////////////////////////////////////////////////////////
//
// Explanation: Holds Text
// * font: int 1 to 5 (inclusively)
// * horiz: boolean (true=horizontal, false=vertical)
//
// Function FText(): Save Position (x,y), Text (text), Font (font), Direction (horiz), Color (color)
// Function draw(): Draw Text on $im
//
//////////////////////////////////////////////////////////////////////
class FText extends FPoint {
private $text; // char *
private $color; // Fcolor
private $font; // int
private $horiz; // bool
public function FText($x,$y,$text,$font,$horiz,FColor $color){
FPoint::FPoint($x,$y);
$this->text = $text;
$this->color = $color;
$this->font = $font;
$this->horiz = $horiz;
DebugTool("*** FText Created");
}
public function draw($im) {
$color = (is_null($this->color))?NULL:$this->color->allocate($im);
if(!is_null($color))
if($this->horiz==true)
imagestring($im,$this->font,$this->x,$this->y,$this->text,$color);
else
imagestringup($im,$this->font,$this->x,$this->y,$this->text,$color);
}
};
//////////////////////////////////////////////////////////////////////
// Class: FDrawing
//////////////////////////////////////////////////////////////////////
//
// Explanation: Holds the drawing $im and can also holds all forms and texts
// * You must call init().
// * You can use get_im() to add other kind of form not
// held into these classes.
//
// Function FDrawing(): Size (w,h), Filename (filename), BackGround Color (color)
// Function init(): Init Image and color background
// Function get_im(): Return $im
// Function add_form(): Add form into the form array (for future drawing)
// Function add_text(): Add text into the text array (for future drawing)
// Function draw_all(): Draw first all forms and after all texts on $im
// Function finish(): Save $im into the file (many format available)
// Function destroy(): Free the memory of PHP (called also by destructor)
//
//////////////////////////////////////////////////////////////////////
class FDrawing {
private $w, $h; // int
private $color; // Fcolor
private $filename; // char *
private $im; // {object}
private $form = array();// Form *
private $text = array();// Ftext *
public function FDrawing($w,$h,$filename,Fcolor $color) {
$this->w = $w;
$this->h = $h;
$this->filename = $filename;
$this->color = $color;
DebugTool("*** FDrawing Created");
}
function __destruct() {
$this->destroy();
}
public function init(){
$this->im = imagecreate($this->w, $this->h)
or die("Can't Initialize the GD Libraty");
imagecolorallocate($this->im,$this->color->r(),$this->color->g(),$this->color->b());
}
public function get_im(){
return $this->im;
}
public function add_form(Form $form){
$this->form[] = $form;
}
public function add_text(Ftext $text){
$this->text[] = $text;
}
public function draw_all(){
for($i=0;$i<count($this->form);$i++)
$this->form[$i]->draw($this->im);
for($i=0;$i<count($this->text);$i++)
$this->text[$i]->draw($this->im);
}
public function finish($image_style=IMG_FORMAT_PNG,$quality=100){
if($image_style==constant("IMG_FORMAT_PNG"))
imagepng($this->im,$this->filename);
elseif($image_style==constant("IMG_FORMAT_JPEG"))
imagejpeg($this->im,$this->filename,$quality);
elseif($image_style==constant("IMG_FORMAT_WBMP"))
imagewbmp($this->im,$this->filename);
elseif($image_style==constant("IMG_FORMAT_GIF"))
imagegif($this->im,$this->filename);
}
public function destroy(){
imagedestroy($this->im);
}
};
?>
Conclusion
Pour ceux qui veulent modifier le code, libre à vous... Il serait bien de m'en avertir et me dire quelle modification vous faites ou vous avez fait pour en faire profiter à tout le monde.
Désolé pour ceux qui n'aiment pas l'anglais, mais je code toujours en anglais maintenant... c'est plus portable entre programmeur :P
Et peut-etre un petit coup de gueule à passer, j'ai codé le plus propre possible et je vous conseille d'en faire AUTANT ! (register_global=Off, short_open_tag=Off, ...) tout ce genre de configurations !
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg
Logiciels
sDEVIS-FACTURES vlPRO (8.1.0.3)SDEVIS-FACTURES VLPRO (8.1.0.3)sDEVIS-FACTURES vlPRO a été mis au point pour les particuliers, créateurs, entrepreneurs, artisa... Cliquez pour télécharger sDEVIS-FACTURES vlPRO 974 Application Server (12.2.4.6)974 APPLICATION SERVER (12.2.4.6)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP
|