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

clip polygonbug #34

Open
eyworldwide opened this issue Sep 28, 2016 · 0 comments
Open

clip polygonbug #34

eyworldwide opened this issue Sep 28, 2016 · 0 comments

Comments

@eyworldwide
Copy link

in renderPolygon method of the canvasRender class:

    // clip of poly if all vertices have been marked for clipping
    var clippoly = 1;
    for (var i=0; i<vertices.length; i++) {
        // console.log(clip)
        clippoly &= clip[vertices[i]];
    }
    if (clippoly) return;

there are cases that all vertices have been marked but still be visible in the canvas:

image

I think it's a hack that i add the condition whether 4 corners of canvas are in the current path or not:

        // HACK: all vertices have been marked but still be visible nearby the 4 corners of the canvas
        var width = this.canvas.width;
        var height = this.canvas.height;
        if(ctx.isPointInPath(0, 0) || ctx.isPointInPath(0, height)
             || ctx.isPointInPath(width, 0) || ctx.isPointInPath(width, height)){
            clippoly = 0;
        }
        if (clippoly) return;

do you have some more elegant solutions?

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