<?php
class Vertex {
public $Father;
public $LP;
public $PP;
public $Type;}
ini_set('display_errors',1);
error_reporting(E_ALL);
$formula1='abcd/*e-+';
$formula='+-e*/dcba';
$dl=strlen($formula);
$image=imagecreate(8,8);
$gold=imagecolorallocate($image, 255, 240, 00);
$red = imagecolorallocate($image, 0, 0, 255);
$blue = imagecolorallocate($image, 255, 0, 0);
$Perem =0;
$x=200;
$y=100;
for ($i = 0; $i <= $dl-1; $i++)
{
$simbol=substr($formula,$i,1);
switch($simbol)
{
case "+": case "-": case "*": case "/":
if ($Perem != 1)
{
$Perem = 1;
$Koren= new Vertex;
$Koren->Type=1;
$last=$Koren;
$Tek=$Koren;
$image = imagecreatetruecolor(18,18);
imagefilledellipse($image, $x, $y, 8, 8, $red);
imagettftext($image, 5, 0, 8, 8, $blue, 'Arial', $simbol);
break;
} else
{
if (($Tek->PP) == null)
{
$x=$x+30; $y=$y+30;
$ttt=$Tek;
$Vert[]->PP=new Vertex;
$Vert[]->Type=1;
$Vert[]->Father=$ttt;
$Tek=$Vert;
$image = imagecreatetruecolor(18,18);
imagefilledellipse($image, $x, $y, 8, 8, $red);
imagettftext($image, 5, 0, 8, 8, $blue, 'Arial', $simbol);
break;
} else
if ($Tek->LP == null)
{
$x=$x-30; $y=$y+30;
$ttt=$Tek;
$Vert[]->LP=new Vertex;
$Vert[]->Type=1;
$Vert[]->Father=$ttt;
$Tek=$Vert;
$image = imagecreatetruecolor(18,18);
imagefilledellipse($image, $x, $y, 8, 8, $red);
imagettftext($image, 5, 0, 8, 8, $blue, 'Arial', $simbol);
break;
}
}
case "a": case "b": case "c": case "d": case "e": case "f":
if (($Tek->PP) == null)
{
$x=$x+30; $y=$y+30;
$ttt=$Tek;
$Vert[]->PP=new Vertex;
$Vert[]->Father=$ttt;
$Vert[]->Type=0;
$Tek=$ttt;
$image = imagecreatetruecolor(18,18);
imagefilledellipse($image, $x, $y, 8, 8, $red);
imagettftext($image, 5, 0, 8, 8, $blue, 'Arial', $simbol);
break;
} else
if (($Tek->LP) == null)
{
$x=$x-30; $y=$y+30;
$ttt=$Tek;
$Vert[]->LP=new Vertex;
$Vert[]->Father=$ttt;
$Vert[]->$Type=0;
$Tek=$ttt;
$image = imagecreatetruecolor(18,18);
imagefilledellipse($image, $x, $y, 8, 8, $red);
imagettftext($image, 5, 0, 8, 8, $blue, 'Arial', $simbol);
break;
} else
Vverh();
}
}
Function Vverh()
{ GLOBAL $Tek, $numb;
$Tek=($Tek->Father);
if (($Tek->PP) == null)
{
$ttt=$tek;
$Vert[]->PP=new Vertex;
$Vert[]->Father=$ttt;
$Vert[]->Type=0;
$Tek=$ttt;
$image = imagecreatetruecolor(18,18);
imagefilledellipse($image, $x, $y, 8, 8, $red);
imagettftext($image, 5, 0, 8, 8, $blue, 'Arial', $simbol);
break;
} else
if (($Tek->LP) == null)
{
$ttt=$tek;
$Vert[]->LP=new Vertex;
$Vert[]->Father=$ttt;
$Vert[]->$Type=0;
$Tek=$ttt;
$image = imagecreatetruecolor(18,18);
imagefilledellipse($image, $x, $y, 8, 8, $red);
imagettftext($image, 5, 0, 8, 8, $blue, 'Arial', $simbol);
break;
} else
Vverh();
}
?>