$points[] = $via[1]; } $scalefactor = $l_new/$l_old; # $log .= "Scale by $scalefactor along link-line"; // rotate so that link is along the axis RotateAboutPoint($points,$pivx, $pivy, deg2rad($angle_old)); // do the scaling in here for($i=0; $i<(count($points)/2); $i++) { $basex = ($points[$i*2] - $pivx) * $scalefactor + $pivx; $points[$i*2] = $basex; } // rotate back so that link is along the new direction RotateAboutPoint($points,$pivx, $pivy, deg2rad(-$angle_new)); // now put the modified points back into the vialist again $v = 0; $i = 0; foreach($points as $p) { // skip a point if it positioned relative to a node. Those shouldn't be rotated (well, IMHO) if(!isset($link->vialist[$v][2])) { $link->vialist[$v][$i]=$p; } $i++; if($i==2) { $i=0; $v++;} } } }
function DrawLabelRotated($im, $x, $y, $angle, $text, $font, $padding, $linkname, $textcolour, $bgcolour, $outlinecolour, &$map, $direction) { list($strwidth, $strheight)=$this->myimagestringsize($font, $text); if(abs($angle)>90) $angle -= 180; if($angle < -180) $angle +=360; $rangle = -deg2rad($angle); $extra=3; $x1= $x - ($strwidth / 2) - $padding - $extra; $x2= $x + ($strwidth / 2) + $padding + $extra; $y1= $y - ($strheight / 2) - $padding - $extra; $y2= $y + ($strheight / 2) + $padding + $extra; // a box. the last point is the start point for the text. $points = array($x1,$y1, $x1,$y2, $x2,$y2, $x2,$y1, $x-$strwidth/2, $y+$strheight/2 + 1); $npoints = count($points)/2; RotateAboutPoint($points, $x,$y, $rangle); if ($bgcolour != array ( -1, -1, -1 )) { $bgcol=myimagecolorallocate($im, $bgcolour[0], $bgcolour[1], $bgcolour[2]); # imagefilledrectangle($im, $x1, $y1, $x2, $y2, $bgcol); wimagefilledpolygon($im,$points,4,$bgcol); } if ($outlinecolour != array ( -1, -1, -1 )) { $outlinecol=myimagecolorallocate($im, $outlinecolour[0], $outlinecolour[1], $outlinecolour[2]); # imagerectangle($im, $x1, $y1, $x2, $y2, $outlinecol); wimagepolygon($im,$points,4,$outlinecol); } $textcol=myimagecolorallocate($im, $textcolour[0], $textcolour[1], $textcolour[2]); $this->myimagestring($im, $font, $points[8], $points[9], $text, $textcol,$angle); $areaname = "LINK:L".$map->links[$linkname]->id.':'.($direction+2); // the rectangle is about half the size in the HTML, and easier to optimise/detect in the browser if($angle==0) { $map->imap->addArea("Rectangle", $areaname, '', array($x1, $y1, $x2, $y2)); wm_debug ("Adding Rectangle imagemap for $areaname\n"); } else { $map->imap->addArea("Polygon", $areaname, '', $points); wm_debug ("Adding Poly imagemap for $areaname\n"); } }