@@ -566,6 +566,7 @@ export class Path implements IPath {
566566 }
567567 constructor ( ) {
568568 this . _path = CGPathCreateMutable ( ) ;
569+ this . _fillType = FillType . WINDING ;
569570 // this._path = UIBezierPath.bezierPath();
570571 }
571572 computeBounds ( rect : RectF , exact : boolean ) {
@@ -1537,7 +1538,7 @@ export class Canvas implements ICanvas {
15371538 @paint
15381539 drawPath ( path : Path , paint : Paint ) : void {
15391540 const ctx = this . ctx ;
1540- this . _drawPath ( paint , ctx , path . getBPath ( ) || path . getCGPath ( ) ) ;
1541+ this . _drawPath ( paint , ctx , path ) ;
15411542 }
15421543 clipOutPath ( path : IPath ) : boolean {
15431544 console . error ( 'Method not implemented:' , 'clipOutPath' ) ;
@@ -1778,24 +1779,29 @@ export class Canvas implements ICanvas {
17781779 }
17791780 private _drawPath ( paint : Paint , ctx , path ?) {
17801781 let bPath : UIBezierPath ;
1781- if ( path instanceof UIBezierPath ) {
1782+ let cgPath = path ;
1783+ if ( path instanceof Path ) {
1784+ bPath = path . getBPath ( ) ;
1785+ cgPath = path . getCGPath ( ) ;
1786+ } else if ( path instanceof UIBezierPath ) {
17821787 bPath = path ;
1783- path = bPath . CGPath ;
1788+ cgPath = bPath . CGPath ;
17841789 }
17851790 function createBPath ( ) {
17861791 if ( ! bPath ) {
1787- if ( ! path ) {
1788- path = CGContextCopyPath ( ctx ) ;
1792+ if ( ! cgPath ) {
1793+ cgPath = CGContextCopyPath ( ctx ) ;
17891794 }
1790- bPath = UIBezierPath . bezierPathWithCGPath ( path ) ;
1795+ bPath = UIBezierPath . bezierPathWithCGPath ( cgPath ) ;
17911796 }
17921797 }
1793- if ( paint . shader && ! path ) {
1794- path = CGContextCopyPath ( ctx ) ;
1798+ if ( paint . shader && ! cgPath ) {
1799+ cgPath = CGContextCopyPath ( ctx ) ;
17951800 }
17961801 if ( path && ( path . _fillType === FillType . INVERSE_WINDING || path . _fillType === FillType . INVERSE_EVEN_ODD ) ) {
17971802 createBPath ( ) ;
17981803 bPath = bPath . bezierPathByReversingPath ( ) ;
1804+ cgPath = bPath . CGPath ;
17991805 }
18001806 if ( paint . pathEffect instanceof DashPathEffect ) {
18011807 createBPath ( ) ;
@@ -1804,12 +1810,12 @@ export class Canvas implements ICanvas {
18041810 bPath . setLineDashCountPhase ( FloatConstructor . from ( intervals ) as any , length , paint . pathEffect . phase ) ;
18051811 }
18061812
1807- if ( path && paint . shader ) {
1813+ if ( cgPath && paint . shader ) {
18081814 if ( paint . style === Style . STROKE ) {
1809- const cgStrokedPath = CGPathCreateCopyByStrokingPath ( path , null , paint . strokeWidth , paint . strokeCap as any , paint . strokeJoin as any , 0 ) ;
1815+ const cgStrokedPath = CGPathCreateCopyByStrokingPath ( cgPath , null , paint . strokeWidth , paint . strokeCap as any , paint . strokeJoin as any , 0 ) ;
18101816 CGContextAddPath ( ctx , cgStrokedPath ) ;
18111817 } else {
1812- CGContextAddPath ( ctx , path ) ;
1818+ CGContextAddPath ( ctx , cgPath ) ;
18131819 }
18141820 paint . drawShader ( ctx , false ) ;
18151821 } else {
@@ -1833,20 +1839,20 @@ export class Canvas implements ICanvas {
18331839 }
18341840 UIGraphicsPopContext ( ) ;
18351841 } else {
1836- if ( path ) {
1837- CGContextAddPath ( ctx , path ) ;
1842+ if ( cgPath ) {
1843+ CGContextAddPath ( ctx , cgPath ) ;
18381844 }
18391845 if ( paint . style === Style . FILL ) {
18401846 // CGContextFillPath(ctx);
1841- if ( path . _fillType === FillType . EVEN_ODD || path . _fillType === FillType . INVERSE_EVEN_ODD ) {
1847+ if ( path && ( path . _fillType === FillType . EVEN_ODD || path . _fillType === FillType . INVERSE_EVEN_ODD ) ) {
18421848 CGContextDrawPath ( ctx , CGPathDrawingMode . kCGPathEOFill ) ;
18431849 } else {
18441850 CGContextDrawPath ( ctx , CGPathDrawingMode . kCGPathFill ) ;
18451851 }
18461852 } else if ( paint . style === Style . STROKE ) {
18471853 CGContextDrawPath ( ctx , CGPathDrawingMode . kCGPathStroke ) ;
18481854 } else {
1849- if ( path . _fillType === FillType . EVEN_ODD || path . _fillType === FillType . INVERSE_EVEN_ODD ) {
1855+ if ( path && ( path . _fillType === FillType . EVEN_ODD || path . _fillType === FillType . INVERSE_EVEN_ODD ) ) {
18501856 CGContextDrawPath ( ctx , CGPathDrawingMode . kCGPathEOFillStroke ) ;
18511857 } else {
18521858 CGContextDrawPath ( ctx , CGPathDrawingMode . kCGPathFillStroke ) ;
0 commit comments