PHP Classes
elePHPant
Icontem

File: mother.Class.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Jonathan Alexey  >  EstGraph  >  mother.Class.php  >  Download  
File: mother.Class.php
Role: Class source
Content type: text/plain
Description: mother_file
Class: EstGraph
Generate an image with a text string
Author: By
Last change: Translete the Portugues to Ingles
Date: 5 years ago
Size: 3,217 bytes
 

Contents

Class file image Download
<?php
//######################################
// >> Created by Jonathan Fontes, for any help or support send a email //jonathan_alexey16@hotmail.com ;)
//
// >> new version coming soon ;)
//
// >> Version 0.9.5
//
// >>the font most have in a folder name "font" exemple : "font/verdana.ttf"
// and other folder is for image save, name it as "_FEG"
//#######################################
*/
class
EstGraph {

    var
$cor_fundo;
    var
$cor;
    var
$img;
    var
$tipo;
    var
$Str;
    var
$erro=0;
    var
$msg_erro="";
    var
$cria=false;
   

    function
EstGraph($x=30,$y=30) {
        if(
$x<30 or $y<30) {
           
$this->erro+=1;
           
$this->msg_erro .= " |!| width or length less than [minimum 30, X=$x - Y=$y]";
        }else{
           
$this->img=imagecreate($x,$y);
           
$this->xx=$x;
           
$this->yy=$y;
        }
    }
   
    function
bgColor ($red=10,$green=10,$blue=10) {
        if(
$red>255 or $red<0 or $green>255 or $green<0 or $blue>255 or $blue<0) {
           
$this->erro+=1;
           
$this->msg_erro .= " |!| Background color most be between 0 and 255";
        } else{
           
$this->cor_fundo=imagecolorallocate($this->img,$red,$green,$blue);
           
imagefill($this->img,0,0,$this->cor_fundo);
        }
    }
   
    function
colorString ($red=0,$green=0,$blue=0) {
        if(
$red>255 or $red<0 or $green>255 or $green<0 or $blue>255 or $blue<0) {
           
$this->erro+=1;
           
$this->msg_erro .= " |!| Color text most be between 0 and 255";
        }else{
           
$this->cor=imagecolorallocate($this->img,$red,$green,$blue);
        }
    }
   
    function
String ($texto,$tamanho="30",$Str_x=0,$Str_y=0,$font="verdana") {
       
$path_font = "_Classes/font/".$font.".ttf";
       
imagettftext($this->img,$tamanho,0,$Str_x,$Str_y,$this->cor,$path_font,$texto);
    }
   
    function
Type ($tip,$nome="memo",$qualidade=80) {
        switch (
$tip) {
            case
"jpeg" :
               
imagejpeg($this->img,"_Classes/_FEG/".$nome.".".$tip,$qualidade);
               
$this->tip=$tip;
            break;
            case
"png" :
                
imagepng($this->img,"_Classes/_FEG/".$nome.".".$tip);
               
$this->tip=$tip;
            break;
            case
"gif" :
                
imagegif($this->img,"_Classes/_FEG/".$nome.".".$tip);
               
$this->tip=$tip;
            break;
            default:
               
$this->erro+=1;
               
$this->msg_erro="Type of file is unknow: ".".".$tip;
            break;
        }
       
$this->tipo=$tip;
       
$this->nome=$nome;
    }
   
    function
outPut() {
       
$this->ReporteErro();
        if(
$this->cria==true) {
            echo
"<img src='_Classes/_FEG/$this->nome.$this->tipo' width='$this->xx' height='$this->yy'>";
           
imagedestroy($this->img);
        }
    }
   
    function
ReportedErro() {
        if(
$this->erro>0) {
                echo
"<b> <h4>--|!|--</h4> <b>Parameters</b> </b></br> ".$this->erro." ".$this->msg_erro;
            }else{
               
$this->cria=true;
        }
    }
}
?>