From 8e553883744381089872ba4cadf29b51bb92ab9f Mon Sep 17 00:00:00 2001 From: Dimitris - Rafail Katsampas Date: Fri, 13 Dec 2024 19:42:01 +0200 Subject: [PATCH 1/2] fix(ui-canvas): Canvas iOS bitmaps incorrect shadow offset-y --- src/ui-canvas/canvas.ios.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ui-canvas/canvas.ios.ts b/src/ui-canvas/canvas.ios.ts index 02e2335..bfc80aa 100644 --- a/src/ui-canvas/canvas.ios.ts +++ b/src/ui-canvas/canvas.ios.ts @@ -1813,7 +1813,11 @@ export class Canvas implements ICanvas { if (paint.shadowLayer) { const s = paint.shadowLayer; - CGContextSetShadowWithColor(ctx, CGSizeMake(s.dx, s.dy), s.radius, s.color.ios.CGColor); + // Bitmaps have their coordinate system flipped vertically and that affects shadows offset + // so flip shadow offset y as well + const offsetY = this.mIsBitmap ? -s.dy : s.dy; + + CGContextSetShadowWithColor(ctx, CGSizeMake(s.dx, offsetY), s.radius, s.color.ios.CGColor); } else { CGContextSetShadow(ctx, CGSizeZero, 0); } From a28331d0d130c3ae7e861a9d1508a1600abd945c Mon Sep 17 00:00:00 2001 From: Dimitris - Rafail Katsampas Date: Fri, 13 Dec 2024 19:59:55 +0200 Subject: [PATCH 2/2] chore: Updated comment --- src/ui-canvas/canvas.ios.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ui-canvas/canvas.ios.ts b/src/ui-canvas/canvas.ios.ts index bfc80aa..ab20160 100644 --- a/src/ui-canvas/canvas.ios.ts +++ b/src/ui-canvas/canvas.ios.ts @@ -1813,8 +1813,7 @@ export class Canvas implements ICanvas { if (paint.shadowLayer) { const s = paint.shadowLayer; - // Bitmaps have their coordinate system flipped vertically and that affects shadows offset - // so flip shadow offset y as well + // Bitmaps have their coordinate system flipped vertically, however shadow offsets ignore this and must be handled manually const offsetY = this.mIsBitmap ? -s.dy : s.dy; CGContextSetShadowWithColor(ctx, CGSizeMake(s.dx, offsetY), s.radius, s.color.ios.CGColor);