@@ -1185,6 +1185,25 @@ export class Paint implements IPaint {
11851185 CGContextDrawRadialGradient ( ctx , g . gradient , CGPointMake ( g . centerX , g . centerY ) , 0 , CGPointMake ( g . centerX , g . centerY ) , g . radius , options ) ;
11861186 CGContextRestoreGState ( ctx ) ;
11871187 // CGContextAddPath(ctx, path);
1188+ } else if ( this . shader instanceof BitmapShader ) {
1189+ const color = UIColor . clearColor ;
1190+ CGContextSetFillColorWithColor ( ctx , color . CGColor ) ;
1191+ CGContextSetStrokeColorWithColor ( ctx , color . CGColor ) ;
1192+ const g = this . shader ;
1193+ const source : UIImage = g . image ;
1194+
1195+ const w = source . size . width ;
1196+ const h = source . size . height ;
1197+ const rect = CGRectMake ( 0 , 0 , w , h ) ;
1198+
1199+ // draw original image
1200+ CGContextSaveGState ( ctx ) ;
1201+ CGContextClip ( ctx ) ;
1202+ CGContextTranslateCTM ( ctx , 0 , source . size . height ) ;
1203+ CGContextScaleCTM ( ctx , 1.0 , - 1.0 ) ;
1204+ CGContextDrawImage ( ctx , rect , source . CGImage ) ;
1205+ CGContextRestoreGState ( ctx ) ;
1206+ // CGContextAddPath(ctx, path);
11881207 }
11891208 }
11901209 _textAttribs : NSMutableDictionary < any , any > ;
@@ -1780,7 +1799,14 @@ export class Canvas implements ICanvas {
17801799 }
17811800
17821801 if ( path && paint . shader ) {
1783- CGContextAddPath ( ctx , path ) ;
1802+ if ( paint . style === Style . STROKE ) {
1803+ const cgStrokedPath = CGPathCreateCopyByStrokingPath ( path , null ,
1804+ paint . strokeWidth , paint . strokeCap as any , paint . strokeJoin as any , 0 ) ;
1805+ CGContextAddPath ( ctx , cgStrokedPath ) ;
1806+ } else {
1807+ CGContextAddPath ( ctx , path ) ;
1808+
1809+ }
17841810 paint . drawShader ( ctx ) ;
17851811 } else {
17861812 if ( bPath ) {
@@ -2134,6 +2160,17 @@ export class RadialGradient {
21342160 }
21352161 }
21362162}
2163+ export class BitmapShader {
2164+ constructor ( public bitmap : any , public tileX : any , public tileY : any ) { }
2165+ get image ( ) {
2166+ if ( this . bitmap instanceof ImageSource ) {
2167+ return this . bitmap . ios ;
2168+ }
2169+ return this . bitmap ;
2170+ }
2171+ release ( ) {
2172+ }
2173+ }
21372174export class PorterDuffXfermode {
21382175 constructor ( public mode ?: number ) { }
21392176}
0 commit comments