@@ -549,7 +549,13 @@ export class DashPathEffect extends PathEffect {
549
549
export class Path implements IPath {
550
550
private mPath : any ;
551
551
private mBPath ?: UIBezierPath ;
552
- mFillType : FillType ;
552
+ private mFillType : FillType ;
553
+
554
+ constructor ( ) {
555
+ this . mPath = CGPathCreateMutable ( ) ;
556
+ this . mFillType = FillType . WINDING ;
557
+ // this._path = UIBezierPath.bezierPath();
558
+ }
553
559
554
560
getOrCreateBPath ( ) {
555
561
if ( ! this . mBPath ) {
@@ -577,11 +583,6 @@ export class Path implements IPath {
577
583
this . mBPath = bPath ;
578
584
// this._path = this._bPath.CGPath;
579
585
}
580
- constructor ( ) {
581
- this . mPath = CGPathCreateMutable ( ) ;
582
- this . mFillType = FillType . WINDING ;
583
- // this._path = UIBezierPath.bezierPath();
584
- }
585
586
computeBounds ( rect : RectF , exact : boolean ) {
586
587
if ( this . mBPath ) {
587
588
rect . cgRect = this . mBPath . bounds ;
@@ -1920,17 +1921,23 @@ export class Canvas implements ICanvas {
1920
1921
CGContextClipToRect ( ctx , rect ) ;
1921
1922
return true ;
1922
1923
}
1923
- private _drawPath ( paint : Paint , ctx , path ?) {
1924
+ private _drawPath ( paint : Paint , ctx , path ?: Path | UIBezierPath ) {
1924
1925
let bPath : UIBezierPath ;
1925
1926
let cgPath ;
1927
+ let fillType : FillType ;
1928
+
1926
1929
if ( path instanceof Path ) {
1927
1930
bPath = path . getBPath ( ) ;
1928
1931
cgPath = path . getCGPath ( ) ;
1929
- } else if ( path instanceof UIBezierPath ) {
1930
- bPath = path ;
1931
- cgPath = bPath . CGPath ;
1932
+ fillType = path . getFillType ( ) ;
1932
1933
} else {
1933
- cgPath = path ;
1934
+ if ( path instanceof UIBezierPath ) {
1935
+ bPath = path ;
1936
+ cgPath = bPath . CGPath ;
1937
+ } else {
1938
+ cgPath = path ;
1939
+ }
1940
+ fillType = FillType . WINDING ;
1934
1941
}
1935
1942
1936
1943
const createBPath = ( ) => {
@@ -1945,7 +1952,7 @@ export class Canvas implements ICanvas {
1945
1952
if ( paint . shader && ! cgPath ) {
1946
1953
cgPath = CGContextCopyPath ( ctx ) ;
1947
1954
}
1948
- if ( path && ( path . getFillType ( ) === FillType . INVERSE_WINDING || path . getFillType ( ) === FillType . INVERSE_EVEN_ODD ) ) {
1955
+ if ( fillType === FillType . INVERSE_WINDING || fillType === FillType . INVERSE_EVEN_ODD ) {
1949
1956
createBPath ( ) ;
1950
1957
bPath = bPath . bezierPathByReversingPath ( ) ;
1951
1958
cgPath = bPath . CGPath ;
@@ -1991,15 +1998,15 @@ export class Canvas implements ICanvas {
1991
1998
}
1992
1999
if ( paint . style === Style . FILL ) {
1993
2000
// CGContextFillPath(ctx);
1994
- if ( path && ( path . getFillType ( ) === FillType . EVEN_ODD || path . getFillType ( ) === FillType . INVERSE_EVEN_ODD ) ) {
2001
+ if ( fillType === FillType . EVEN_ODD || fillType === FillType . INVERSE_EVEN_ODD ) {
1995
2002
CGContextDrawPath ( ctx , CGPathDrawingMode . kCGPathEOFill ) ;
1996
2003
} else {
1997
2004
CGContextDrawPath ( ctx , CGPathDrawingMode . kCGPathFill ) ;
1998
2005
}
1999
2006
} else if ( paint . style === Style . STROKE ) {
2000
2007
CGContextDrawPath ( ctx , CGPathDrawingMode . kCGPathStroke ) ;
2001
2008
} else {
2002
- if ( path && ( path . getFillType ( ) === FillType . EVEN_ODD || path . getFillType ( ) === FillType . INVERSE_EVEN_ODD ) ) {
2009
+ if ( fillType === FillType . EVEN_ODD || fillType === FillType . INVERSE_EVEN_ODD ) {
2003
2010
CGContextDrawPath ( ctx , CGPathDrawingMode . kCGPathEOFillStroke ) ;
2004
2011
} else {
2005
2012
CGContextDrawPath ( ctx , CGPathDrawingMode . kCGPathFillStroke ) ;
0 commit comments