From afc857a9d4fb244e854347ceb69ca8567d707a18 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Mon, 2 Jan 2017 14:27:09 -0800 Subject: [PATCH] rename variables to match blog post --- p3k/geo/StaticMap.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/p3k/geo/StaticMap.php b/p3k/geo/StaticMap.php index e1093c0..024e60c 100644 --- a/p3k/geo/StaticMap.php +++ b/p3k/geo/StaticMap.php @@ -439,25 +439,28 @@ function generate($params, $filename, $assetPath) { $angle = 1 * k($params, 'bezier'); // Midpoint between the two ends - $A = [ + $M = [ 'x' => ($from['x'] + $to['x']) / 2, 'y' => ($from['y'] + $to['y']) / 2 ]; // Derived from http://math.stackexchange.com/a/383648 and http://www.wolframalpha.com/input/?i=triangle+%5B1,1%5D+%5B5,2%5D+%5B1-1%2Fsqrt(3),1%2B4%2Fsqrt(3)%5D - $B = $from; + // See for details - $C = [ - 'x' => ($A['x']) - (($B['y']-$A['y']) * tan(deg2rad($angle))), - 'y' => ($A['y']) + (($B['x']-$A['x']) * tan(deg2rad($angle))) + $A = $from; + $B = $to; + + $P = [ + 'x' => ($M['x']) - (($A['y']-$M['y']) * tan(deg2rad($angle))), + 'y' => ($M['y']) + (($A['x']-$M['x']) * tan(deg2rad($angle))) ]; $draw->pathStart(); - $draw->pathMoveToAbsolute($from['x']-$leftEdge,$from['y']-$topEdge); + $draw->pathMoveToAbsolute($A['x']-$leftEdge,$A['y']-$topEdge); $draw->pathCurveToQuadraticBezierAbsolute( - $C['x']-$leftEdge, $C['y']-$topEdge, - $to['x']-$leftEdge, $to['y']-$topEdge + $P['x']-$leftEdge, $P['y']-$topEdge, + $B['x']-$leftEdge, $B['y']-$topEdge ); $draw->pathFinish(); } else {