@@ -1233,14 +1233,20 @@ export class Paint implements IPaint {
1233
1233
1234
1234
const w = source . size . width ;
1235
1235
const h = source . size . height ;
1236
- const rect = CGRectMake ( 0 , 0 , w , h ) ;
1236
+ const rect = new Rect ( CGRectMake ( 0 , 0 , w , h ) ) ;
1237
+
1238
+ let transform = CGAffineTransformMakeTranslation ( 0 , rect . cgRect . size . height ) ;
1239
+ transform = CGAffineTransformScale ( transform , 1.0 , - 1.0 ) ;
1240
+ if ( this . shader . localMatrix ) {
1241
+ this . shader . localMatrix . mapRect ( rect ) ;
1242
+ }
1243
+ rect . cgRect = CGRectApplyAffineTransform ( rect . cgRect , transform ) ;
1237
1244
1238
1245
// draw original image
1239
1246
CGContextSaveGState ( ctx ) ;
1240
1247
CGContextClip ( ctx ) ;
1241
- CGContextTranslateCTM ( ctx , 0 , source . size . height ) ;
1242
- CGContextScaleCTM ( ctx , 1.0 , - 1.0 ) ;
1243
- CGContextDrawImage ( ctx , rect , source . CGImage ) ;
1248
+ CGContextConcatCTM ( ctx , transform ) ;
1249
+ CGContextDrawImage ( ctx , rect . cgRect , source . CGImage ) ;
1244
1250
CGContextRestoreGState ( ctx ) ;
1245
1251
// CGContextAddPath(ctx, path);
1246
1252
}
@@ -2206,9 +2212,33 @@ export class ColorMatrixColorFilter {
2206
2212
}
2207
2213
}
2208
2214
}
2209
- export class RadialGradient {
2215
+
2216
+ class Shader {
2217
+ localMatrix : Matrix ;
2218
+
2219
+ getLocalMatrix ( localM : Matrix ) : boolean {
2220
+ if ( this . localMatrix && ! this . localMatrix . isIdentity ( ) ) {
2221
+ localM . set ( this . localMatrix ) ;
2222
+ return true ;
2223
+ }
2224
+ return false ;
2225
+ }
2226
+ setLocalMatrix ( localM : Matrix ) {
2227
+ if ( localM ) {
2228
+ if ( ! this . localMatrix ) {
2229
+ this . localMatrix = new Matrix ( ) ;
2230
+ }
2231
+ this . localMatrix . set ( localM ) ;
2232
+ } else {
2233
+ this . localMatrix = null ;
2234
+ }
2235
+ }
2236
+ }
2237
+ export class RadialGradient extends Shader {
2210
2238
mGradient ;
2211
- constructor ( public centerX : number , public centerY : number , public radius : number , public colors : any , public stops : any , public tileMode : TileMode ) { }
2239
+ constructor ( public centerX : number , public centerY : number , public radius : number , public colors : any , public stops : any , public tileMode : TileMode ) {
2240
+ super ( ) ;
2241
+ }
2212
2242
get gradient ( ) {
2213
2243
if ( ! this . mGradient ) {
2214
2244
if ( Array . isArray ( this . colors ) ) {
@@ -2230,8 +2260,10 @@ export class RadialGradient {
2230
2260
}
2231
2261
}
2232
2262
}
2233
- export class BitmapShader {
2234
- constructor ( public bitmap : any , public tileX : any , public tileY : any ) { }
2263
+ export class BitmapShader extends Shader {
2264
+ constructor ( public bitmap : any , public tileX : any , public tileY : any ) {
2265
+ super ( ) ;
2266
+ }
2235
2267
get image ( ) {
2236
2268
if ( this . bitmap instanceof ImageSource ) {
2237
2269
return this . bitmap . ios ;
0 commit comments