sacuba / explorercanvas

Automatically exported from code.google.com/p/explorercanvas
0 stars 0 forks source link

excanvas.js does not support isPointInPath(x, y) #38

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Load iecanvastest.html on IE and on Firefox
2. Observe alerts on Firefox for inside triangle - true then false
3. Observe failure and "Object doesn't support this method" on IE

What is the expected output? What do you see instead?
Expected: two alerts - true, then false. Instead: Javascript alert.

What version of the product are you using? On what operating system?
SVN revision 62.

Please provide any additional information below.

Here's a function for detecting a point inside a path that might help,
although it will be necessary to apply the matrix transformations first.

function pointInPoly(pos, poly) {
    /* This code is patterned after [Franklin, 2000]
    http://www.geometryalgorithms.com/Archive/algorithm_0103/algorithm_0103.htm
    Tells us if the point is in this polygon */
    cn = 0
    pts = poly.slice();
    pts.push([poly[0][0], poly[0][1]]);
    for (i=0; i<poly.length; i++)
        if (((pts[i][1] <= pos[1]) && (pts[i+1][1] > pos[1])) || ((pts[i][1] >
pos[1]) && (pts[i+1][1] <= pos[1])))
            if (pos[0] < pts[i][0] + (pos[1] - pts[i][1]) / (pts[i+1][1] -
pts[i][1]) * (pts[i+1][0] - pts[i][0]))
    cn += 1
    return cn % 2
}

Original issue reported on code.google.com by mccor...@gmail.com on 14 Jun 2009 at 8:58

Attachments:

GoogleCodeExporter commented 9 years ago
Hi, I think it will be hard in javacript to do this, because :
- Transform matrix
- Not polygon path (arcTo and so on...)

Original comment by maitred...@gmail.com on 17 Sep 2009 at 2:55

GoogleCodeExporter commented 9 years ago
Hi guys, is the implementation of this method really not possible for IE?

I would be very glateful for an answer.

Hanna

Original comment by HannaSop...@web.de on 6 Sep 2010 at 11:41