Skip to content

Commit

Permalink
fix(ui-canvas): iOS Path arcTo() sweep angle treat module 360 (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
CatchABus authored Aug 3, 2024
1 parent d60ee44 commit e55da2a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ui-canvas/canvas.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,13 +640,17 @@ export class Path implements IPath {
}
arcTo(rect: Rect, startAngle: number, sweepAngle: number, forceMoveTo?: boolean) {
const center = CGPointMake(rect.centerX(), rect.centerY());
// This is how Android does things in arcTo
const endAngle = (startAngle + sweepAngle) % 360;

let t = CGAffineTransformMakeTranslation(center.x, center.y);
t = CGAffineTransformConcat(CGAffineTransformMakeScale(1.0, rect.height() / rect.width()), t);

if (this.mBPath) {
this.mBPath.addArcWithCenterRadiusStartAngleEndAngleClockwise(center, rect.width() / 2, (startAngle * Math.PI) / 180, ((startAngle + sweepAngle) * Math.PI) / 180, sweepAngle < 0);
this.mBPath.addArcWithCenterRadiusStartAngleEndAngleClockwise(center, rect.width() / 2, (startAngle * Math.PI) / 180, (endAngle * Math.PI) / 180, sweepAngle < 0);
this.mBPath.applyTransform(t);
} else {
CGPathAddArc(this.mPath, new interop.Reference(t), 0, 0, rect.width() / 2, (startAngle * Math.PI) / 180, ((startAngle + sweepAngle) * Math.PI) / 180, sweepAngle < 0);
CGPathAddArc(this.mPath, new interop.Reference(t), 0, 0, rect.width() / 2, (startAngle * Math.PI) / 180, (endAngle * Math.PI) / 180, sweepAngle < 0);
}
}
//@ts-ignore
Expand Down

0 comments on commit e55da2a

Please sign in to comment.