echo "Rendering " . count($zones) . " zones\n"; $normx = $bounds->l / 2; $normy = $bounds->t / 2; $width = $bounds->r / 2 - $bounds->l / 2 + 1; $height = $bounds->b / 2 - $bounds->t / 2 + 1; $img = imagecreate($width, $height); $white = imagecolorallocate($img, 255, 255, 255); foreach ($zones as $_zid) { $_zone = new Zone($_zid); $ft = new EdgeTracer($_zone); drawPoints($img, $ft->edges, allocateColor($img), $normx, $normy); echo sprintf("Processing Zone %s (%d,%d) - (%d,%d)\n", $_zone->name, $_zone->halfbounds->l, $_zone->halfbounds->t, $_zone->halfbounds->r, $_zone->halfbounds->b); $file = 'trace-' . $_zid; //tempnam('./','trace'); echo sprintf("Write PBM (%d,%d)\n", $_zone->halfwidth, $_zone->halfheight); $_zone->writePBM($file . '.pbm'); echo "Process PBM\n"; $polys = array(); exec(sprintf("potrace -b svg -W%d.pt -O1 -n -c -q -u1 -o %s.svg %s.pbm", $_zone->halfwidth, $file, $file)); echo "Parse SVG\n"; $polys = parsePolygonsFromSVG($file . '.svg', $_zone->halfbounds); // exec(sprintf("potrace -b xfig -W%d.pt -o %s.fig %s.pbm", $_zone->halfwidth, $file, $file)); // $xf = new XFIGParser($file.'.fig'); // $xf->parse($_zone->halfbounds); // $polys = $xf->polys; writePolys($_zone, $polys, $file . '.poly'); foreach ($polys as $_poly) { #var_dump($_poly); echo "Rendering Poly for " . $_zid . " of size " . count($_poly) . "\n"; $color = allocateColor($img); drawPoly($img, $_poly, $color, $normx, $normy);