PHP Classes

File: sampleToUse.php

Recommend this page to a friend!
  Classes of Jonathan Alexey   EstGraph   sampleToUse.php   Download  
File: sampleToUse.php
Role: Example script
Content type: text/plain
Description: Help to use class EstGraph
Class: EstGraph
Generate an image with a text string
Author: By
Last change: Translate to Portuguese for Ingles
Date: 14 years ago
Size: 5,563 bytes
 

Contents

Class file image Download
<?php
include("../classes/EstGraph.php");

//sample 1 // exemplo 1

$img=new EstGraph();
$img->EstGraph(400,200);
$img->bgColor(200,100,300);
$img->colorString(255,255,255);
$img->String("Hello world by Jonathan",20,5,10,"TCM");
$img->Type("jpeg","teste",200);
$img->outPut();
?>
/*#############
## sample 2 // exemplo 2 ##
##############
 mais complexo com font ttf em pasta|| Copy and paste this sample into your server, and test
################
*/

<!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=windows-1250" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#form1 #red {
    height: 15px;
    width: 30px;
}
#form1 #green {
    height: 15px;
    width: 30px;
}
#form1 #blue {
    height: 15px;
    width: 30px;
}
#form1 #r_t {
    height: 15px;
    width: 30px;
}
#form1 #g_t {
    height: 15px;
    width: 30px;
}
#form1 #b_t {
    height: 15px;
    width: 30px;
}
-->
</style>
</head>

<body>
<p>
  <?php
include("/_Classes/EstGraph.php");

if(isset(
$_POST['texto']) and $_POST['texto']!="") {
    if(
$_POST['x']!="" and $_POST['y']!="") {
        if(
$_POST['green']!="" and $_POST['blue'] and $_POST['red']!="") {
           
$tex=$_POST['texto'];
           
$i=new EstGraph($_POST['x'],$_POST['y']);
           
$i->bgColor($_POST['red'],$_POST['green'],$_POST['blue']);
           
$i->colorString($_POST['r_t'],$_POST['g_t'],$_POST['b_t']);
           
$i->String($tex,$_POST['tamanho'],10,20,$_POST['font']);
           
$i->type("jpeg",$_POST['nome'],200);
           
$i->outPut();
        }
    }
}
//jpeg

?></p>
<form id="form1" name="form1" method="post" action="">
  <table width="100%" border="0">
    <tr>
      <td colspan="2"><h3>Tamanho da imagem</h3></td>
      <td width="15%">&nbsp;</td>
      <td width="58%">&nbsp;</td>
    </tr>
    <tr>
      <td width="12%"><p>xx:</p></td>
      <td width="15%"><input name="x" type="text" id="x" value="<?php if(isset($_POST['x']) and $_POST['x']!="") { echo $_POST['x']; } ?>" /></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>yy:</td>
      <td><input name="y" type="text" id="y" value="<?php if(isset($_POST['y']) and $_POST['y']!="") { echo $_POST['y']; } ?>" /></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2"><h3>Cor de fundo</h3></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>Vermelho-
        <input name="red" type="text" id="red" value="<?php if(isset($_POST['red']) and $_POST['red']!="") { echo $_POST['red']; } ?>" /></td>
      <td>Verde-
      <input type="text" name="green" id="green" value="<?php if(isset($_POST['green']) and $_POST['green']!="") { echo $_POST['green']; } ?>" /></td>
      <td>Azul-
      <input type="text" name="blue" id="blue" value="<?php if(isset($_POST['blue']) and $_POST['blue']!="") { echo $_POST['blue']; } ?>" /></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2"><h3>Formata&ccedil;a&atilde;o de texto</h3></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2">Vermelho-
        <input type="text" name="r_t" id="r_t" value="<?php if(isset($_POST['r_t']) and $_POST['r_t']!="") { echo $_POST['r_t']; } ?>" />
Verde-
<input type="text" name="g_t" id="g_t" value="<?php if(isset($_POST['g_t']) and $_POST['g_t']!="") { echo $_POST['g_t']; } ?>" />
Azul-
<input type="text" name="b_t" id="b_t" value="<?php if(isset($_POST['b_t']) and $_POST['b_t']!="") { echo $_POST['b_t']; } ?>" /></td>
      <td>Font:
        <select name="font" id="font">
          <option value="verdana" selected="selected">Verdana</option>
          <option value="mangal">Mangal</option>
          <option value="TCM">Tw Cent</option>
          <option value="BROADW">Broadway</option>
          <option value="CENTURY">Century</option>
        </select></td>
      <td>Tamanho:
        <select name="tamanho" id="tamanho">
          <option value="10" selected="selected">Tamanho</option>
          <option value="10">0 pt</option>
          <option value="12">12 pt</option>
          <option value="14">14 pt</option>
          <option value="15">15 pt</option>
          <option value="16">16 pt</option>
          <option value="17">17 pt</option>
        </select></td>
    </tr>
    <tr>
      <td colspan="2"><h3>Nome da imagem</h3></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>Nome:</td>
      <td><input name="nome" type="text" id="nome" value="<?php if(isset($_POST['nome']) and $_POST['nome']!="") { echo $_POST['nome']; } ?>" /></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2"><h3>Texto:</h3></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="4"><textarea name="texto" id="texto" cols="45" rows="5"><?php if(isset($_POST['texto']) and $_POST['texto']!="") { echo $_POST['texto']; } ?>
</textarea></td>
    </tr>
   
    <tr>
      <td><input type="submit" name="button" id="button" value="Criar" /></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
  <p><a href="<?php echo "_Classes/_FEG/".$_POST['nome'].".jpeg"; ?>"><?php if(isset($_POST['nome']) and $_POST['nome']!="") { ?>Baixar imagem<?php } ?></a></p>
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>