diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2007-02-08 11:11:42 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2007-02-08 11:11:42 +0000 |
commit | b8f51740e26dee3f8fdd937dcaac7f0d437fe785 (patch) | |
tree | 9026ecfae7b979a1ee6d1554521d2e33e783c108 /src/interfaces | |
parent | 47c7a25d15c25ae051af381046b8257e9b2a9a46 (diff) | |
download | zetacomponents-graph-b8f51740e26dee3f8fdd937dcaac7f0d437fe785.zip zetacomponents-graph-b8f51740e26dee3f8fdd937dcaac7f0d437fe785.tar.gz |
- Implemented ellipse size reducement in flash driver
Diffstat (limited to 'src/interfaces')
-rw-r--r-- | src/interfaces/driver.php | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/interfaces/driver.php b/src/interfaces/driver.php index 5c3b755..e8d5adb 100644 --- a/src/interfaces/driver.php +++ b/src/interfaces/driver.php @@ -205,8 +205,6 @@ abstract class ezcGraphDriver * 'center' => (ezcGraphCoordinate) New center point, * 'start' => (ezcGraphCoordinate) New outer start point, * 'end' => (ezcGraphCoordinate) New outer end point, - * 'startAngle' => (float) Angle from old center point to new start point, - * 'endAngle' => (float) Angle from old center point to new end point, * ) * * @param ezcGraphCoordinate $center @@ -232,19 +230,21 @@ abstract class ezcGraphDriver $endAngle = deg2rad( $endAngle ); // Calculate normalized vectors for the lines spanning the ellipse - $startVector = ezcGraphVector::fromCoordinate( $oldStartPoint )->unify(); - $endVector = ezcGraphVector::fromCoordinate( $oldEndPoint )->unify(); + $unifiedStartVector = ezcGraphVector::fromCoordinate( $oldStartPoint )->unify(); + $unifiedEndVector = ezcGraphVector::fromCoordinate( $oldEndPoint )->unify(); + $startVector = ezcGraphVector::fromCoordinate( $oldStartPoint ); + $endVector = ezcGraphVector::fromCoordinate( $oldEndPoint ); $oldStartPoint->add( $center ); $oldEndPoint->add( $center ); // Use orthogonal vectors of normalized ellipse spanning vectors to - $v = clone $startVector; + $v = clone $unifiedStartVector; $v->rotateClockwise()->scalar( $size ); // calculate new center point // center + v + size / tan( angle / 2 ) * startVector - $centerMovement = clone $startVector; + $centerMovement = clone $unifiedStartVector; $newCenter = $v->add( $centerMovement->scalar( $size / tan( ( $endAngle - $startAngle ) / 2 ) ) )->add( $center ); // Use start spanning vector and its orthogonal vector to calculate @@ -266,10 +266,12 @@ abstract class ezcGraphDriver ); // Reverse spanning vector - $innerVector = clone $startVector; + $innerVector = clone $unifiedStartVector; $innerVector->scalar( $size )->scalar( -1 ); $newStartPoint->add( $innerVector)->add( $ellipseTangentVector->scalar( $size ) ); + $newStartVector = clone $startVector; + $newStartVector->add( $ellipseTangentVector ); // Use end spanning vector and its orthogonal vector to calculate // new end point @@ -290,15 +292,19 @@ abstract class ezcGraphDriver ); // Reverse spanning vector - $innerVector = clone $endVector; + $innerVector = clone $unifiedEndVector; $innerVector->scalar( $size )->scalar( -1 ); $newEndPoint->add( $innerVector )->add( $ellipseTangentVector->scalar( $size )->scalar( -1 ) ); + $newEndVector = clone $endVector; + $newEndVector->add( $ellipseTangentVector ); return array( 'center' => $newCenter, 'start' => $newStartPoint, 'end' => $newEndPoint, + 'startAngle' => rad2deg( $startAngle + $startVector->angle( $newStartVector ) ), + 'endAngle' => rad2deg( $endAngle - $endVector->angle( $newEndVector ) ), ); } |