@@ -494,19 +494,19 @@ export class Matrix implements IMatrix {
494
494
return CGAffineTransformIsIdentity ( this . mTransform ) ;
495
495
}
496
496
// public toString(): string {
497
- // return NSStringFromCGAffineTransform(this._transform );
497
+ // return NSStringFromCGAffineTransform(this.mTransform );
498
498
// }
499
499
public preTranslate ( tx : number , ty : number ) : boolean {
500
500
return this . preConcat ( CGAffineTransformMakeTranslation ( tx , ty ) ) ;
501
501
}
502
502
public setValues ( values : number [ ] ) : void {
503
503
this . mTransform = CGAffineTransformMake ( values [ 0 ] , values [ 3 ] , values [ 1 ] , values [ 4 ] , values [ 2 ] , values [ 5 ] ) ;
504
- // this._transform .a = values[0];
505
- // this._transform .c = values[1];
506
- // this._transform .tx = values[2];
507
- // this._transform .b = values[3];
508
- // this._transform .d = values[4];
509
- // this._transform .ty = values[5];
504
+ // this.mTransform .a = values[0];
505
+ // this.mTransform .c = values[1];
506
+ // this.mTransform .tx = values[2];
507
+ // this.mTransform .b = values[3];
508
+ // this.mTransform .d = values[4];
509
+ // this.mTransform .ty = values[5];
510
510
}
511
511
public invert ( output : IMatrix ) : boolean {
512
512
( output as Matrix ) . mTransform = CGAffineTransformInvert ( this . mTransform ) ;
@@ -1693,30 +1693,42 @@ export class Canvas implements ICanvas {
1693
1693
const path = args [ 0 ] as Path ;
1694
1694
const op = args [ 1 ] as Op ;
1695
1695
const ctx = this . ctx ;
1696
+
1697
+ let clipCGPath ;
1698
+
1696
1699
if ( op !== undefined ) {
1697
1700
const cgPath = ctx . path ;
1698
- let clipPath = cgPath ? UIBezierPath . bezierPathWithCGPath ( cgPath ) : UIBezierPath . bezierPathWithRect ( CGRectMake ( 0 , 0 , this . mWidth , this . mHeight ) ) ;
1701
+ let clipBPath = cgPath ? UIBezierPath . bezierPathWithCGPath ( cgPath ) : UIBezierPath . bezierPathWithRect ( CGRectMake ( 0 , 0 , this . mWidth , this . mHeight ) ) ;
1702
+
1699
1703
if ( op === Op . DIFFERENCE ) {
1700
- clipPath . appendPath ( path . getOrCreateBPath ( ) . bezierPathByReversingPath ( ) ) ;
1704
+ clipBPath . appendPath ( path . getOrCreateBPath ( ) . bezierPathByReversingPath ( ) ) ;
1701
1705
} else if ( op === Op . REVERSE_DIFFERENCE ) {
1702
- clipPath = clipPath . bezierPathByReversingPath ( ) ;
1703
- clipPath . appendPath ( path . getOrCreateBPath ( ) ) ;
1706
+ clipBPath = clipBPath . bezierPathByReversingPath ( ) ;
1707
+ clipBPath . appendPath ( path . getOrCreateBPath ( ) ) ;
1704
1708
} else if ( op === Op . UNION ) {
1705
- clipPath . appendPath ( path . getOrCreateBPath ( ) ) ;
1709
+ clipBPath . appendPath ( path . getOrCreateBPath ( ) ) ;
1706
1710
} else if ( op === Op . REPLACE ) {
1707
1711
CGContextResetClip ( ctx ) ;
1708
- clipPath = path . getOrCreateBPath ( ) ;
1712
+ clipBPath = path . getOrCreateBPath ( ) ;
1709
1713
} else if ( op === Op . INTERSECT ) {
1710
1714
console . error ( 'clipPath Op.INTERSECT not implemented yet' ) ;
1711
1715
} else if ( op === Op . XOR ) {
1712
1716
console . error ( 'clipPath Op.INTERSECT not implemented yet' ) ;
1713
1717
}
1714
- CGContextAddPath ( ctx , clipPath . CGPath ) ;
1715
- CGContextClip ( ctx ) ;
1718
+
1719
+ clipCGPath = clipBPath . CGPath ;
1720
+ } else {
1721
+ clipCGPath = path . getCGPath ( ) ;
1722
+ }
1723
+
1724
+ CGContextAddPath ( ctx , clipCGPath ) ;
1725
+
1726
+ if ( path . getFillType ( ) === FillType . EVEN_ODD || path . getFillType ( ) === FillType . INVERSE_EVEN_ODD ) {
1727
+ CGContextEOClip ( ctx ) ;
1716
1728
} else {
1717
- CGContextAddPath ( ctx , path . getCGPath ( ) ) ;
1718
1729
CGContextClip ( ctx ) ;
1719
1730
}
1731
+
1720
1732
// clipPath(path: IPath): boolean;
1721
1733
// clipPath(path: IPath, op: Op): boolean;
1722
1734
// clipPath(path: any, op?: any)
@@ -1920,18 +1932,20 @@ export class Canvas implements ICanvas {
1920
1932
} else {
1921
1933
cgPath = path ;
1922
1934
}
1923
- function createBPath ( ) {
1935
+
1936
+ const createBPath = ( ) => {
1924
1937
if ( ! bPath ) {
1925
1938
if ( ! cgPath ) {
1926
1939
cgPath = CGContextCopyPath ( ctx ) ;
1927
1940
}
1928
1941
bPath = UIBezierPath . bezierPathWithCGPath ( cgPath ) ;
1929
1942
}
1930
- }
1943
+ } ;
1944
+
1931
1945
if ( paint . shader && ! cgPath ) {
1932
1946
cgPath = CGContextCopyPath ( ctx ) ;
1933
1947
}
1934
- if ( path && ( path . _fillType === FillType . INVERSE_WINDING || path . _fillType === FillType . INVERSE_EVEN_ODD ) ) {
1948
+ if ( path && ( path . getFillType ( ) === FillType . INVERSE_WINDING || path . getFillType ( ) === FillType . INVERSE_EVEN_ODD ) ) {
1935
1949
createBPath ( ) ;
1936
1950
bPath = bPath . bezierPathByReversingPath ( ) ;
1937
1951
cgPath = bPath . CGPath ;
@@ -1977,15 +1991,15 @@ export class Canvas implements ICanvas {
1977
1991
}
1978
1992
if ( paint . style === Style . FILL ) {
1979
1993
// CGContextFillPath(ctx);
1980
- if ( path && ( path . _fillType === FillType . EVEN_ODD || path . _fillType === FillType . INVERSE_EVEN_ODD ) ) {
1994
+ if ( path && ( path . getFillType ( ) === FillType . EVEN_ODD || path . getFillType ( ) === FillType . INVERSE_EVEN_ODD ) ) {
1981
1995
CGContextDrawPath ( ctx , CGPathDrawingMode . kCGPathEOFill ) ;
1982
1996
} else {
1983
1997
CGContextDrawPath ( ctx , CGPathDrawingMode . kCGPathFill ) ;
1984
1998
}
1985
1999
} else if ( paint . style === Style . STROKE ) {
1986
2000
CGContextDrawPath ( ctx , CGPathDrawingMode . kCGPathStroke ) ;
1987
2001
} else {
1988
- if ( path && ( path . _fillType === FillType . EVEN_ODD || path . _fillType === FillType . INVERSE_EVEN_ODD ) ) {
2002
+ if ( path && ( path . getFillType ( ) === FillType . EVEN_ODD || path . getFillType ( ) === FillType . INVERSE_EVEN_ODD ) ) {
1989
2003
CGContextDrawPath ( ctx , CGPathDrawingMode . kCGPathEOFillStroke ) ;
1990
2004
} else {
1991
2005
CGContextDrawPath ( ctx , CGPathDrawingMode . kCGPathFillStroke ) ;
0 commit comments