Skip to content

Commit 1c294a2

Browse files
committed
fix: ios fix for color and alpha to behave like android
1 parent 6dc1392 commit 1c294a2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/canvas.ios.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,9 +1042,16 @@ export class Paint implements IPaint {
10421042
} else {
10431043
this._color = undefined;
10441044
}
1045-
}
1046-
setColor(color: Color | number | string) {
1047-
this.color = color as any;
1045+
if (this._color) {
1046+
// on android setColor sets the alpha too
1047+
const c = this._color;
1048+
this.alpha = c.a;
1049+
// we want to ignore color alpha because on android it is not used but
1050+
// on ios it will add up
1051+
this._color = new Color(255, c.r, c.g, c.b);
1052+
} else {
1053+
this.alpha = 255;
1054+
}
10481055

10491056
}
10501057
getColor(): Color {

0 commit comments

Comments
 (0)