Skip to content

Commit d60ee44

Browse files
authored
fix(ui-canvas): Path constructor invalid parameter (#63)
* fix(ui-canvas): Path constructor did not accept a parameter of the same type * fix(ui-canvas): Added iOS Path missing constructor parameter
1 parent d9f64c7 commit d60ee44

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/ui-canvas/canvas.android.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,14 @@ export class ColorMatrixColorFilter extends ProxyClass<android.graphics.ColorMat
347347
export class Path extends ProxyClass<com.akylas.canvas.CanvasPath> {
348348
constructor(path?: com.akylas.canvas.CanvasPath) {
349349
super();
350-
this.mNative = path ? new com.akylas.canvas.CanvasPath(path) : new com.akylas.canvas.CanvasPath();
350+
351+
if (path) {
352+
const param = (path as any).getNative ? (path as any).getNative() : path;
353+
this.mNative = new com.akylas.canvas.CanvasPath(param);
354+
} else {
355+
this.mNative = new com.akylas.canvas.CanvasPath();
356+
}
357+
351358
return this;
352359
}
353360
}

src/ui-canvas/canvas.ios.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,8 @@ export class Path implements IPath {
551551
private mBPath?: UIBezierPath;
552552
private mFillType: FillType;
553553

554-
constructor() {
555-
this.mPath = CGPathCreateMutable();
554+
constructor(path?: Path) {
555+
this.mPath = path ? CGPathCreateMutableCopy(path.getCGPath()) : CGPathCreateMutable();
556556
this.mFillType = FillType.WINDING;
557557
// this._path = UIBezierPath.bezierPath();
558558
}
@@ -611,7 +611,7 @@ export class Path implements IPath {
611611
if (points.length <= 0 || points.length % 2 !== 0) {
612612
console.error('wrong points number');
613613
}
614-
UIBezierPath.addLinesOffsetCountCloseToPath(points, offset, length, close, this.mPath);
614+
UIBezierPath.addLinesOffsetCountCloseToPath(points, offset, length, close, this.getCGPath());
615615
}
616616
setLines(points: number[], offset?: number, length?: number, close?: boolean) {
617617
this.reset();
@@ -632,7 +632,7 @@ export class Path implements IPath {
632632
// if (close === true) {
633633
// CGPathCloseSubpath(this._path);
634634
// }
635-
UIBezierPath.addCubicLinesOffsetCountCloseToPath(points, offset, length, close, this.mPath);
635+
UIBezierPath.addCubicLinesOffsetCountCloseToPath(points, offset, length, close, this.getCGPath());
636636
}
637637
setCubicLines(points: number[], offset?: number, length?: number, close?: boolean) {
638638
this.reset();
@@ -909,7 +909,7 @@ export class Path implements IPath {
909909
//@ts-ignore
910910
set(path: Path): void {
911911
this.mBPath = null;
912-
this.mPath = CGPathCreateMutableCopy(path.mPath);
912+
this.mPath = CGPathCreateMutableCopy(path.getCGPath());
913913
}
914914
}
915915

0 commit comments

Comments
 (0)