Beispiel #1
0
 /**
  * Function: getBoundingBox
  * 
  * Returns the bounding box for the rotated rectangle.
  */
 static function getBoundingBox($rect, $rotation)
 {
     $result = null;
     if ($rect != null && $rotation != null && $rotation != 0) {
         $rad = mxUtils::toRadians($rotation);
         $cos = cos($rad);
         $sin = sin($rad);
         $cx = new mxPoint($rect->x + $rect->width / 2, $rect->y + $rect->height / 2);
         $p1 = new mxPoint($rect->x, $rect->y);
         $p2 = new mxPoint($rect->x + $rect->width, $rect->y);
         $p3 = new mxPoint($p2->x, $rect->y + $rect->height);
         $p4 = new mxPoint($rect->x, $p3->y);
         $p1 = mxUtils::getRotatedPoint($p1, $cos, $sin, $cx);
         $p2 = mxUtils::getRotatedPoint($p2, $cos, $sin, $cx);
         $p3 = mxUtils::getRotatedPoint($p3, $cos, $sin, $cx);
         $p4 = mxUtils::getRotatedPoint($p4, $cos, $sin, $cx);
         $result = new mxRectangle($p1->x, $p1->y, 0, 0);
         $result . add(new mxRectangle($p2->x, $p2->y, 0, 0));
         $result . add(new mxRectangle($p3->x, $p3->y, 0, 0));
         $result . add(new mxRectangle($p4->x, $p4->y, 0, 0));
     }
     return $result;
 }