{"id":19339698,"url":"https://github.com/rubenv/point-in-svg-polygon","last_synced_at":"2025-05-12T14:54:13.697Z","repository":{"id":58230648,"uuid":"51915443","full_name":"rubenv/point-in-svg-polygon","owner":"rubenv","description":"Determine if an point is inside a polygon","archived":false,"fork":false,"pushed_at":"2019-09-14T20:32:38.000Z","size":137,"stargazers_count":82,"open_issues_count":3,"forks_count":17,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-10T10:07:35.973Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubenv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-17T10:46:00.000Z","updated_at":"2024-08-14T12:27:46.000Z","dependencies_parsed_at":"2022-08-30T20:01:37.757Z","dependency_job_id":null,"html_url":"https://github.com/rubenv/point-in-svg-polygon","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenv%2Fpoint-in-svg-polygon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenv%2Fpoint-in-svg-polygon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenv%2Fpoint-in-svg-polygon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenv%2Fpoint-in-svg-polygon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubenv","download_url":"https://codeload.github.com/rubenv/point-in-svg-polygon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253759404,"owners_count":21959761,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T03:23:26.456Z","updated_at":"2025-05-12T14:54:13.667Z","avatar_url":"https://github.com/rubenv.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# point-in-svg-polygon\n\n\u003e Determine if an point is inside a polygon\n\n[![Build Status](https://travis-ci.org/rubenv/point-in-svg-polygon.png?branch=master)](https://travis-ci.org/rubenv/point-in-svg-polygon)\n\nWorks with arbitrary polygons (as in: curves!) and is usable in Node.JS as well\nas in your browser (through Browserify).\n\n## What it does\n\nGiven an SVG path and a point, it'll tell you whether the point lies within the SVG path.\n\nFor instance:\n\n![example shapes](example.png)\n\nColor  | Inside red shape (convex)? | Inside blue shape (concave)?\n------ | -------------------------- | ----------------------------\nRed    | No                         | No\nGreen  | Yes                        | Yes\nBlue   | Yes                        | No\nOrange | No                         | Yes\n\n## Usage\n\nGive it a point and a path string:\n\n```js\nvar pointInSvgPolygon = require(\"point-in-svg-polygon\");\n\n// See the path specification for the correct format\n// https://developer.mozilla.org/en/docs/Web/SVG/Tutorial/Paths\nvar pathString = \"M1,1 C1,1 501,1 501,501 C501,1001 1,1001 1,1001 L1,1 Z\";\nvar result = pointInSvgPolygon.isInside([x, y], pathString);\n```\n\nYou can amortize the path splitting by performing it once:\n\n```js\nvar pointInSvgPolygon = require(\"point-in-svg-polygon\");\n\n// See the path specification for the correct format\n// https://developer.mozilla.org/en/docs/Web/SVG/Tutorial/Paths\nvar pathString = \"M1,1 C1,1 501,1 501,501 C501,1001 1,1001 1,1001 L1,1 Z\";\nvar segments = pointInSvgPolygon.segments(pathString);\n\n// Use it multiple times:\nvar result = pointInSvgPolygon.isInside([x, y], segments);\n```\n\nThis is useful if you have to test a lot of points.\n\n## Credits\n\nOriginally based on [the work by Kevin\nLindsey](http://www.kevlindev.com/geometry/2D/intersections/index.htm). Severly\ntrimmed down: 6.3Kb footprint when minified, drops down to 2.9Kb when gzipped.\n\n## License \n\n    Copyright (c) 2016, Ruben Vermeersch\n    Copyright (c) 2013, Kevin Lindsey\n    All rights reserved.\n\n    Redistribution and use in source and binary forms, with or without modification,\n    are permitted provided that the following conditions are met:\n\n      Redistributions of source code must retain the above copyright notice, this\n      list of conditions and the following disclaimer.\n\n      Redistributions in binary form must reproduce the above copyright notice, this\n      list of conditions and the following disclaimer in the documentation and/or\n      other materials provided with the distribution.\n\n      Neither the name of the {organization} nor the names of its\n      contributors may be used to endorse or promote products derived from\n      this software without specific prior written permission.\n\n    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\n    ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n    ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubenv%2Fpoint-in-svg-polygon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubenv%2Fpoint-in-svg-polygon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubenv%2Fpoint-in-svg-polygon/lists"}