Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Matrix.mapPoints one parameter version iOS #32

Open
stemyke opened this issue Feb 25, 2021 · 1 comment
Open

Missing Matrix.mapPoints one parameter version iOS #32

stemyke opened this issue Feb 25, 2021 · 1 comment

Comments

@stemyke
Copy link

stemyke commented Feb 25, 2021

@farfromrefug Can you please modify the function this way in canvas.ios.ts?

public mapPoints(...args) {
        let src: number[];
        let dstIndex: number = 0,
            srcIndex: number = 0,
            pointCount: number;
        const pts: number[] = args[0];
        if (args.length <= 2) {
            src = args[args.length-1];
        } else {
            dstIndex = args[1] || 0;
            srcIndex = args[3] || 0;
            pointCount = args[4];
            src = args[2];
        }
        src = src || pts;
        pointCount = Math.floor(pointCount || src.length);
        for (let index = 0; index < pointCount; index += 2) {
            const cgPoint = CGPointApplyAffineTransform(CGPointMake(src[index + srcIndex], src[index + srcIndex + 1]), this._transform);
            pts[index + dstIndex] = cgPoint.x;
            pts[index + dstIndex + 1] = cgPoint.y;
        }
    }
@stemyke
Copy link
Author

stemyke commented Feb 25, 2021

@farfromrefug And I think actually the pointCount variable should be treated as actual count of x,y points, not the separated numeric values.

pointCount = Math.floor(pointCount || (src.length / 2));
for (let index = 0; index < pointCount; index++) {
    const cgPoint = CGPointApplyAffineTransform(CGPointMake(src[index + srcIndex], src[index + srcIndex + 1]), this._transform);
    pts[index * 2 + dstIndex] = cgPoint.x;
    pts[index * 2 + dstIndex + 1] = cgPoint.y;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant