86 lines
2 KiB
PHP
Executable file
86 lines
2 KiB
PHP
Executable file
<form action=gen2.php method=post>
|
|
<textarea name=story cols=100 rows=20></textarea><input type=submit>
|
|
</form>
|
|
|
|
|
|
<?
|
|
error_reporting(E_ALL);
|
|
|
|
$voff=0;
|
|
$hoff=0;
|
|
$vmax=5000;
|
|
|
|
function draw_glyph($x,$y,$text){
|
|
global $voff,$vmax,$hoff;
|
|
$fn="/var/www/vec/vec/".substr($text,0,1)."/".substr($text,1,1)."/".$text.".svg";
|
|
if(!file_exists($fn)){
|
|
echo "No file $text<br>";
|
|
return;
|
|
}
|
|
$fd=file($fn);
|
|
$fdt=implode($fd);
|
|
$fd[0]="";
|
|
|
|
$tsplit=split("height=\"",$fdt);
|
|
$tsplit=split("\"",$tsplit[1]);
|
|
$voff+=$tsplit[0];
|
|
//echo "($voff+=".$tsplit[0].")";
|
|
|
|
if($voff>$vmax){
|
|
$voff=$tsplit[0];
|
|
$y=0;
|
|
$hoff+=120;
|
|
$x=$hoff;
|
|
}
|
|
|
|
$fd[1]=" <g transform=\"translate($x,$y)\">";
|
|
$fd=implode($fd)."</g>";
|
|
//echo "[".$voff."]";
|
|
|
|
//echo $fd.$fn;
|
|
return $fd;
|
|
}
|
|
|
|
//header("Content-type: image/svg+xml");
|
|
$filed= "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>
|
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
<svg width=\"10000\" height=\"5000\">";
|
|
|
|
$intext=$_POST['story'];
|
|
$intext=str_replace("."," . ",$intext);
|
|
$intext=str_replace("\n"," [new] ",$intext);
|
|
$intext=str_replace("\r","",$intext);
|
|
$intext=str_replace("\""," \" ",$intext);
|
|
$intext=str_replace("\\"," \\ ",$intext);
|
|
$intext=str_replace(","," , ",$intext);
|
|
$intext=str_replace("!"," ! ",$intext);
|
|
$intext=str_replace("?"," ? ",$intext);
|
|
$intext=str_replace(":"," : ",$intext);
|
|
$intext=str_replace(";"," ; ",$intext);
|
|
$intext=str_replace("-"," - ",$intext);
|
|
|
|
$intext=strtolower($intext);
|
|
$stext=split(" ",$intext);
|
|
for($i=0;$i<count($stext);$i++){
|
|
//echo "[$thisw]$hoff,$voff<br>";
|
|
$thisw=trim($stext[$i]);
|
|
if($thisw=="[new]"){
|
|
$voff=0;
|
|
$hoff+=200;
|
|
}
|
|
$filed.= draw_glyph($hoff,$voff,$thisw);
|
|
if(strlen($thisw)>0)$voff+=5;
|
|
}
|
|
|
|
//$filed.= draw_glyph(1,$voff,"fox");
|
|
//$filed.= draw_glyph(1,$voff,"and");
|
|
//$filed.= draw_glyph(1,$voff,"the");
|
|
$filed.="</svg>";
|
|
echo $filed;
|
|
|
|
$myFile = "testFile.svg";
|
|
$fh = fopen($myFile, 'w') or die("can't open file");
|
|
fwrite($fh, $filed);
|
|
fclose($fh);
|
|
|
|
|