@@ -734,6 +734,7 @@ var FlatTintPipeline = new Class({
734734 var path = null ;
735735 var sin = Math . sin ;
736736 var cos = Math . cos ;
737+ var PI2 = Math . PI * 2 ;
737738 var sr = sin ( srcRotation ) ;
738739 var cr = cos ( srcRotation ) ;
739740 var sra = cr * srcScaleX ;
@@ -775,31 +776,51 @@ var FlatTintPipeline = new Class({
775776 endAngle = commands [ cmdIndex + 5 ] ;
776777 anticlockwise = commands [ cmdIndex + 6 ] ;
777778
779+ if ( lastPath === null )
780+ {
781+ lastPath = new Path ( x + cos ( startAngle ) * radius , y + sin ( startAngle ) * radius , lineWidth , lineColor , lineAlpha ) ;
782+ pathArray . push ( lastPath ) ;
783+ iteration += iterStep ;
784+ }
785+
786+ endAngle -= startAngle ;
778787 if ( anticlockwise )
779788 {
780- ta = endAngle ;
781- endAngle = startAngle ;
782- startAngle = - ta ;
789+ if ( endAngle < - PI2 )
790+ {
791+ endAngle = - PI2 ;
792+ }
793+ else if ( endAngle > 0 )
794+ {
795+ endAngle = - PI2 + endAngle % PI2 ;
796+ }
797+ }
798+ else if ( endAngle > PI2 )
799+ {
800+ endAngle = PI2 ;
783801 }
784-
802+ else if ( endAngle < 0 )
803+ {
804+ endAngle = PI2 + endAngle % PI2 ;
805+ }
806+
785807 while ( iteration < 1 )
786808 {
787- ta = ( endAngle - startAngle ) * iteration + startAngle ;
809+ ta = endAngle * iteration + startAngle ;
788810 tx = x + cos ( ta ) * radius ;
789811 ty = y + sin ( ta ) * radius ;
790812
791- if ( iteration === 0 )
792- {
793- lastPath = new Path ( tx , ty , lineWidth , lineColor , lineAlpha ) ;
794- pathArray . push ( lastPath ) ;
795- }
796- else
797- {
798- lastPath . points . push ( new Point ( tx , ty , lineWidth , lineColor , lineAlpha ) ) ;
799- }
813+ lastPath . points . push ( new Point ( tx , ty , lineWidth , lineColor , lineAlpha ) ) ;
800814
801815 iteration += iterStep ;
802816 }
817+
818+ ta = endAngle + startAngle ;
819+ tx = x + cos ( ta ) * radius ;
820+ ty = y + sin ( ta ) * radius ;
821+
822+ lastPath . points . push ( new Point ( tx , ty , lineWidth , lineColor , lineAlpha ) ) ;
823+
803824 cmdIndex += 6 ;
804825 break ;
805826
@@ -818,16 +839,13 @@ var FlatTintPipeline = new Class({
818839
819840 case Commands . BEGIN_PATH :
820841 pathArray . length = 0 ;
842+ lastPath = null ;
821843 break ;
822844
823845 case Commands . CLOSE_PATH :
824- if ( lastPath !== null && lastPath . points . length > 0 )
846+ if ( lastPath && lastPath . points . length )
825847 {
826- var firstPoint = lastPath . points [ 0 ] ;
827- var lastPoint = lastPath . points [ lastPath . points . length - 1 ] ;
828- lastPath . points . push ( firstPoint ) ;
829- lastPath = new Path ( lastPoint . x , lastPoint . y , lastPoint . width , lastPoint . rgb , lastPoint . alpha ) ;
830- pathArray . push ( lastPath ) ;
848+ lastPath . points . push ( lastPath . points [ 0 ] ) ;
831849 }
832850 break ;
833851
0 commit comments