@@ -177,7 +177,6 @@ export class Rect implements IRect {
177
177
178
178
private updateCGRect ( ) {
179
179
this . cgRect = createCGRect ( this . _left , this . _top , this . _right , this . _bottom ) ;
180
-
181
180
}
182
181
183
182
get left ( ) {
@@ -1107,7 +1106,6 @@ export class Paint implements IPaint {
1107
1106
} else {
1108
1107
this . alpha = 255 ;
1109
1108
}
1110
-
1111
1109
}
1112
1110
getColor ( ) : Color {
1113
1111
return this . _color ;
@@ -1388,13 +1386,18 @@ export class Canvas implements ICanvas {
1388
1386
if ( ! image ) {
1389
1387
return ;
1390
1388
}
1391
- const dst = args [ 2 ] instanceof Rect ? args [ 2 ] . cgRect : CGRectMake ( args [ 1 ] , args [ 2 ] , image . size . width , image . size . height ) ;
1392
1389
1393
- // CGContextSaveGState(ctx);
1394
- CGContextTranslateCTM ( ctx , 0 , dst . origin . y + dst . size . height ) ;
1395
- CGContextScaleCTM ( ctx , 1.0 , - 1.0 ) ;
1396
- CGContextDrawImage ( ctx , CGRectMake ( dst . origin . x , 0 , dst . size . width , dst . size . height ) , image . CGImage ) ;
1397
- // CGContextRestoreGState(ctx);
1390
+ if ( args [ 1 ] instanceof Matrix ) {
1391
+ CGContextConcatCTM ( ctx , args [ 1 ] . _transform ) ;
1392
+ CGContextTranslateCTM ( ctx , 0 , image . size . height ) ;
1393
+ CGContextScaleCTM ( ctx , 1.0 , - 1.0 ) ;
1394
+ CGContextDrawImage ( ctx , CGRectMake ( 0 , 0 , image . size . width , image . size . height ) , image . CGImage ) ;
1395
+ } else {
1396
+ const dst = args [ 2 ] instanceof Rect ? args [ 2 ] . cgRect : CGRectMake ( args [ 1 ] , args [ 2 ] , image . size . width , image . size . height ) ;
1397
+ CGContextTranslateCTM ( ctx , 0 , dst . origin . y + dst . size . height ) ;
1398
+ CGContextScaleCTM ( ctx , 1.0 , - 1.0 ) ;
1399
+ CGContextDrawImage ( ctx , CGRectMake ( dst . origin . x , 0 , dst . size . width , dst . size . height ) , image . CGImage ) ;
1400
+ }
1398
1401
}
1399
1402
1400
1403
drawPoint ( x : number , y : number , paint : Paint ) : void {
@@ -1551,11 +1554,10 @@ export class Canvas implements ICanvas {
1551
1554
const op = args [ 1 ] as Op ;
1552
1555
const ctx = this . ctx ;
1553
1556
if ( op !== undefined ) {
1554
- const cgPath = ctx . path ;
1557
+ const cgPath = ctx . path ;
1555
1558
let clipPath = cgPath ? UIBezierPath . bezierPathWithCGPath ( cgPath ) : UIBezierPath . bezierPathWithRect ( CGRectMake ( 0 , 0 , this . _width , this . _height ) ) ;
1556
1559
if ( op === Op . DIFFERENCE ) {
1557
1560
clipPath . appendPath ( path . getOrCreateBPath ( ) . bezierPathByReversingPath ( ) ) ;
1558
-
1559
1561
} else if ( op === Op . REVERSE_DIFFERENCE ) {
1560
1562
clipPath = clipPath . bezierPathByReversingPath ( ) ;
1561
1563
clipPath . appendPath ( path . getOrCreateBPath ( ) ) ;
@@ -1748,12 +1750,12 @@ export class Canvas implements ICanvas {
1748
1750
this . _drawPath ( paint , ctx ) ;
1749
1751
}
1750
1752
1751
- @paint
1752
- drawImage ( x : number , y : number , w : number , h : number , image : ImageSource | UIImage ) {
1753
- const ctx = this . ctx ;
1754
- const theImage : UIImage = image instanceof ImageSource ? image . ios : image ;
1755
- CGContextDrawImage ( ctx , createCGRect ( x , y , w , h ) , theImage . CGImage ) ;
1756
- }
1753
+ // @paint
1754
+ // drawImage(x: number, y: number, w: number, h: number, image: ImageSource | UIImage) {
1755
+ // const ctx = this.ctx;
1756
+ // const theImage: UIImage = image instanceof ImageSource ? image.ios : image;
1757
+ // CGContextDrawImage(ctx, createCGRect(x, y, w, h), theImage.CGImage);
1758
+ // }
1757
1759
clipRect ( ...params ) {
1758
1760
const ctx = this . ctx ;
1759
1761
const length = params . length ;
@@ -1800,12 +1802,10 @@ export class Canvas implements ICanvas {
1800
1802
1801
1803
if ( path && paint . shader ) {
1802
1804
if ( paint . style === Style . STROKE ) {
1803
- const cgStrokedPath = CGPathCreateCopyByStrokingPath ( path , null ,
1804
- paint . strokeWidth , paint . strokeCap as any , paint . strokeJoin as any , 0 ) ;
1805
+ const cgStrokedPath = CGPathCreateCopyByStrokingPath ( path , null , paint . strokeWidth , paint . strokeCap as any , paint . strokeJoin as any , 0 ) ;
1805
1806
CGContextAddPath ( ctx , cgStrokedPath ) ;
1806
1807
} else {
1807
1808
CGContextAddPath ( ctx , path ) ;
1808
-
1809
1809
}
1810
1810
paint . drawShader ( ctx ) ;
1811
1811
} else {
@@ -2169,8 +2169,7 @@ export class BitmapShader {
2169
2169
}
2170
2170
return this . bitmap ;
2171
2171
}
2172
- release ( ) {
2173
- }
2172
+ release ( ) { }
2174
2173
}
2175
2174
export class PorterDuffXfermode {
2176
2175
constructor ( public mode ?: number ) { }
@@ -2185,7 +2184,7 @@ export class StaticLayout {
2185
2184
// } else if (!(text instanceof NSMutableAttributedString)) {
2186
2185
// text = NSMutableAttributedString.alloc().initWithStringAttributes(text, this.paint.getDrawTextAttribs());
2187
2186
} else {
2188
- this . nsAttributedString = NSAttributedString . alloc ( ) . initWithString ( text + ' ' ) ;
2187
+ this . nsAttributedString = NSAttributedString . alloc ( ) . initWithString ( text + ' ' ) ;
2189
2188
}
2190
2189
}
2191
2190
toDraw : NSMutableAttributedString ;
0 commit comments