@@ -138,7 +138,6 @@ public function start($attributes)
138
138
$ tempControlY = null ;
139
139
$ l = 0 ; //-((this.width / 2) + $this.pathOffset.x),
140
140
$ t = 0 ; //-((this.height / 2) + $this.pathOffset.y),
141
- $ methodName = null ;
142
141
143
142
foreach ($ path as $ current ) {
144
143
switch ($ current [0 ]) { // first letter
@@ -333,23 +332,16 @@ public function start($attributes)
333
332
$ tempX = $ x + $ current [1 ];
334
333
$ tempY = $ y + $ current [2 ];
335
334
336
- if (preg_match ("/[QqTt]/ " , $ previous [0 ])) {
337
- // If there is no previous command or if the previous command was not a Q, q, T or t,
338
- // assume the control point is coincident with the current point
335
+ // calculate reflection of previous control points
336
+ if (preg_match ('/[QqT]/ ' , $ previous [0 ])) {
337
+ $ controlX = 2 * $ x - $ controlX ;
338
+ $ controlY = 2 * $ y - $ controlY ;
339
+ } elseif ($ previous [0 ] === 't ' ) {
340
+ $ controlX = 2 * $ x - $ tempControlX ;
341
+ $ controlY = 2 * $ y - $ tempControlY ;
342
+ } else {
339
343
$ controlX = $ x ;
340
344
$ controlY = $ y ;
341
- } else {
342
- if ($ previous [0 ] === 't ' ) {
343
- // calculate reflection of previous control points for t
344
- $ controlX = 2 * $ x - $ tempControlX ;
345
- $ controlY = 2 * $ y - $ tempControlY ;
346
- } else {
347
- if ($ previous [0 ] === 'q ' ) {
348
- // calculate reflection of previous control points for q
349
- $ controlX = 2 * $ x - $ controlX ;
350
- $ controlY = 2 * $ y - $ controlY ;
351
- }
352
- }
353
345
}
354
346
355
347
$ tempControlX = $ controlX ;
@@ -363,17 +355,21 @@ public function start($attributes)
363
355
);
364
356
$ x = $ tempX ;
365
357
$ y = $ tempY ;
366
- $ controlX = $ x + $ current [1 ];
367
- $ controlY = $ y + $ current [2 ];
368
358
break ;
369
359
370
360
case 'T ' :
371
361
$ tempX = $ current [1 ];
372
362
$ tempY = $ current [2 ];
373
363
374
364
// calculate reflection of previous control points
375
- $ controlX = 2 * $ x - $ controlX ;
376
- $ controlY = 2 * $ y - $ controlY ;
365
+ if (preg_match ('/[QqTt]/ ' , $ previous [0 ])) {
366
+ $ controlX = 2 * $ x - $ controlX ;
367
+ $ controlY = 2 * $ y - $ controlY ;
368
+ } else {
369
+ $ controlX = $ x ;
370
+ $ controlY = $ y ;
371
+ }
372
+
377
373
$ surface ->quadraticCurveTo (
378
374
$ controlX + $ l ,
379
375
$ controlY + $ t ,
@@ -385,7 +381,6 @@ public function start($attributes)
385
381
break ;
386
382
387
383
case 'a ' :
388
- // TODO: optimize this
389
384
$ this ->drawArc (
390
385
$ surface ,
391
386
$ x + $ l ,
0 commit comments