{"id":20767793,"url":"https://github.com/dmnsgn/perspective-grid","last_synced_at":"2025-10-16T10:19:25.092Z","repository":{"id":51377587,"uuid":"44622003","full_name":"dmnsgn/perspective-grid","owner":"dmnsgn","description":"Two point perspective grid on canvas","archived":false,"fork":false,"pushed_at":"2024-07-07T14:33:35.000Z","size":1324,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-06T21:57:45.634Z","etag":null,"topics":["canvas","grid","perspective"],"latest_commit_sha":null,"homepage":"http://dmnsgn.github.io/perspective-grid/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dmnsgn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"custom":["https://paypal.me/dmnsgn","https://commerce.coinbase.com/checkout/56cbdf28-e323-48d8-9c98-7019e72c97f3"]}},"created_at":"2015-10-20T17:09:38.000Z","updated_at":"2024-09-23T21:04:54.000Z","dependencies_parsed_at":"2025-04-30T11:35:01.293Z","dependency_job_id":null,"html_url":"https://github.com/dmnsgn/perspective-grid","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/dmnsgn/perspective-grid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmnsgn%2Fperspective-grid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmnsgn%2Fperspective-grid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmnsgn%2Fperspective-grid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmnsgn%2Fperspective-grid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmnsgn","download_url":"https://codeload.github.com/dmnsgn/perspective-grid/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmnsgn%2Fperspective-grid/sbom","scorecard":{"id":348193,"data":{"date":"2025-08-11","repo":{"name":"github.com/dmnsgn/perspective-grid","commit":"217a134b673af3874debf21c73aa6b8d8a645240"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 1/18 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: MIT License: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 3 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T07:40:26.726Z","repository_id":51377587,"created_at":"2025-08-18T07:40:26.727Z","updated_at":"2025-08-18T07:40:26.727Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279177672,"owners_count":26120010,"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","status":"online","status_checked_at":"2025-10-16T02:00:06.019Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["canvas","grid","perspective"],"created_at":"2024-11-17T11:33:26.253Z","updated_at":"2025-10-16T10:19:25.063Z","avatar_url":"https://github.com/dmnsgn.png","language":"JavaScript","funding_links":["https://paypal.me/dmnsgn","https://commerce.coinbase.com/checkout/56cbdf28-e323-48d8-9c98-7019e72c97f3"],"categories":[],"sub_categories":[],"readme":"# perspective-grid\n\n[![npm version](https://img.shields.io/npm/v/perspective-grid)](https://www.npmjs.com/package/perspective-grid)\n[![stability-stable](https://img.shields.io/badge/stability-stable-green.svg)](https://www.npmjs.com/package/perspective-grid)\n[![npm minzipped size](https://img.shields.io/bundlephobia/minzip/perspective-grid)](https://bundlephobia.com/package/perspective-grid)\n[![dependencies](https://img.shields.io/librariesio/release/npm/perspective-grid)](https://github.com/dmnsgn/perspective-grid/blob/main/package.json)\n[![types](https://img.shields.io/npm/types/perspective-grid)](https://github.com/microsoft/TypeScript)\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-fa6673.svg)](https://conventionalcommits.org)\n[![styled with prettier](https://img.shields.io/badge/styled_with-Prettier-f8bc45.svg?logo=prettier)](https://github.com/prettier/prettier)\n[![linted with eslint](https://img.shields.io/badge/linted_with-ES_Lint-4B32C3.svg?logo=eslint)](https://github.com/eslint/eslint)\n[![license](https://img.shields.io/github/license/dmnsgn/perspective-grid)](https://github.com/dmnsgn/perspective-grid/blob/main/LICENSE.md)\n\nTwo point perspective grid on canvas.\n\n[![paypal](https://img.shields.io/badge/donate-paypal-informational?logo=paypal)](https://paypal.me/dmnsgn)\n[![coinbase](https://img.shields.io/badge/donate-coinbase-informational?logo=coinbase)](https://commerce.coinbase.com/checkout/56cbdf28-e323-48d8-9c98-7019e72c97f3)\n[![twitter](https://img.shields.io/twitter/follow/dmnsgn?style=social)](https://twitter.com/dmnsgn)\n\n![](https://raw.githubusercontent.com/dmnsgn/perspective-grid/main/screenshot.gif)\n\n## Installation\n\n```bash\nnpm install perspective-grid\n```\n\n## Usage\n\n```js\nimport { PerspectiveGrid, Point } from \"perspective-grid\";\nimport canvasContext from \"canvas-context\";\n\nconst { context, canvas } = canvasContext(\"2d\", {\n  width: window.innerWidth,\n  height: window.innerHeight,\n});\n\n// Alternatively pass [rows, columns] for a grid with different rows and column units\nconst grid = new PerspectiveGrid(10);\n\ngrid.init(\n  new Point(300, 380),\n  new Point(canvas.width - 300, 300),\n  new Point(canvas.width, canvas.height),\n  new Point(0, canvas.height)\n);\ngrid.update();\n\n// Operations on lines...\ncontext.save();\ngrid.drawLines(context);\ncontext.restore();\n\ncontext.save();\ngrid.drawSquares(context);\ncontext.restore();\n\n// ...or simply draw\ncontext.save();\ngrid.draw(context);\ncontext.restore();\n```\n\n## API\n\n\u003c!-- api-start --\u003e\n\n## Modules\n\n\u003cdl\u003e\n\u003cdt\u003e\u003ca href=\"#module_LineEquation\"\u003eLineEquation\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#module_LineType\"\u003eLineType\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#module_MathHelper\"\u003eMathHelper\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#module_PerspectiveGrid\"\u003ePerspectiveGrid\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#module_Point\"\u003ePoint\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#module_Segment\"\u003eSegment\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003c/dd\u003e\n\u003c/dl\u003e\n\n\u003ca name=\"module_LineEquation\"\u003e\u003c/a\u003e\n\n## LineEquation\n\n- [LineEquation](#module_LineEquation)\n  - [LineEquation](#exp_module_LineEquation--LineEquation) ⏏\n    - [new LineEquation(lineParams, x)](#new_module_LineEquation--LineEquation_new)\n    - [.intersect(equation)](#module_LineEquation--LineEquation+intersect) ⇒ \u003ccode\u003ePoint\u003c/code\u003e\n\n\u003ca name=\"exp_module_LineEquation--LineEquation\"\u003e\u003c/a\u003e\n\n### LineEquation ⏏\n\nLineEquation defines a line equation or vertical\n\n**Kind**: Exported class\n\u003ca name=\"new_module_LineEquation--LineEquation_new\"\u003e\u003c/a\u003e\n\n#### new LineEquation(lineParams, x)\n\n| Param      | Type                    | Description     |\n| ---------- | ----------------------- | --------------- |\n| lineParams | \u003ccode\u003eLineParams\u003c/code\u003e | Line parameters |\n| x          | \u003ccode\u003enumber\u003c/code\u003e     | X position      |\n\n\u003ca name=\"module_LineEquation--LineEquation+intersect\"\u003e\u003c/a\u003e\n\n#### lineEquation.intersect(equation) ⇒ \u003ccode\u003ePoint\u003c/code\u003e\n\nGet intersection of two line equation\n\n**Kind**: instance method of [\u003ccode\u003eLineEquation\u003c/code\u003e](#exp_module_LineEquation--LineEquation)\n\n| Param    | Type                      |\n| -------- | ------------------------- |\n| equation | \u003ccode\u003eLineEquation\u003c/code\u003e |\n\n\u003ca name=\"module_LineType\"\u003e\u003c/a\u003e\n\n## LineType\n\n\u003ca name=\"exp_module_LineType--LineType\"\u003e\u003c/a\u003e\n\n### LineType ⏏\n\nA faked ENUM for referencing line types.\n\n**Kind**: Exported constant\n\n| Param      | Type                |\n| ---------- | ------------------- |\n| VERTICAL   | \u003ccode\u003enumber\u003c/code\u003e |\n| HORIZONTAL | \u003ccode\u003enumber\u003c/code\u003e |\n\n\u003ca name=\"module_MathHelper\"\u003e\u003c/a\u003e\n\n## MathHelper\n\n- [MathHelper](#module_MathHelper)\n  - [.EPSILON](#module_MathHelper.EPSILON) : \u003ccode\u003enumber\u003c/code\u003e\n  - [.PI](#module_MathHelper.PI) : \u003ccode\u003enumber\u003c/code\u003e\n  - [.TWO_PI](#module_MathHelper.TWO_PI) : \u003ccode\u003enumber\u003c/code\u003e\n  - [.getDistance(point1, point2)](#module_MathHelper.getDistance) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n  - [.getConvergencePoint(m1, c1, m2, c2)](#module_MathHelper.getConvergencePoint) ⇒ \u003ccode\u003ePoint\u003c/code\u003e\n  - [.getVerticalConvergence(x, m, c)](#module_MathHelper.getVerticalConvergence) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n  - [.getLineParams(x1, y1, x2, y2)](#module_MathHelper.getLineParams) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n  - [.getParallelLine(line, point)](#module_MathHelper.getParallelLine) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n  - [.getDistanceToLine(line, point)](#module_MathHelper.getDistanceToLine) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n  - [.getProjectedPoint(line, point)](#module_MathHelper.getProjectedPoint) ⇒ \u003ccode\u003ePoint\u003c/code\u003e\n  - [.getMassCenter(p1, p2, p3, p4)](#module_MathHelper.getMassCenter) ⇒ \u003ccode\u003ePoint\u003c/code\u003e\n\n\u003ca name=\"module_MathHelper.EPSILON\"\u003e\u003c/a\u003e\n\n### MathHelper.EPSILON : \u003ccode\u003enumber\u003c/code\u003e\n\n**Kind**: static constant of [\u003ccode\u003eMathHelper\u003c/code\u003e](#module_MathHelper)\n\u003ca name=\"module_MathHelper.PI\"\u003e\u003c/a\u003e\n\n### MathHelper.PI : \u003ccode\u003enumber\u003c/code\u003e\n\n**Kind**: static constant of [\u003ccode\u003eMathHelper\u003c/code\u003e](#module_MathHelper)\n\u003ca name=\"module_MathHelper.TWO_PI\"\u003e\u003c/a\u003e\n\n### MathHelper.TWO_PI : \u003ccode\u003enumber\u003c/code\u003e\n\n**Kind**: static constant of [\u003ccode\u003eMathHelper\u003c/code\u003e](#module_MathHelper)\n\u003ca name=\"module_MathHelper.getDistance\"\u003e\u003c/a\u003e\n\n### MathHelper.getDistance(point1, point2) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n\nGet the distance between two points\n\n**Kind**: static method of [\u003ccode\u003eMathHelper\u003c/code\u003e](#module_MathHelper)\n**Returns**: \u003ccode\u003enumber\u003c/code\u003e - Distance between point1 and point2\n\n| Param  | Type                | Description  |\n| ------ | ------------------- | ------------ |\n| point1 | \u003ccode\u003eObject\u003c/code\u003e | First point  |\n| point2 | \u003ccode\u003eObject\u003c/code\u003e | Second point |\n\n\u003ca name=\"module_MathHelper.getConvergencePoint\"\u003e\u003c/a\u003e\n\n### MathHelper.getConvergencePoint(m1, c1, m2, c2) ⇒ \u003ccode\u003ePoint\u003c/code\u003e\n\nGet the convergence point of two line equation\n\n**Kind**: static method of [\u003ccode\u003eMathHelper\u003c/code\u003e](#module_MathHelper)\n\n| Param | Type                |\n| ----- | ------------------- |\n| m1    | \u003ccode\u003enumber\u003c/code\u003e |\n| c1    | \u003ccode\u003enumber\u003c/code\u003e |\n| m2    | \u003ccode\u003enumber\u003c/code\u003e |\n| c2    | \u003ccode\u003enumber\u003c/code\u003e |\n\n\u003ca name=\"module_MathHelper.getVerticalConvergence\"\u003e\u003c/a\u003e\n\n### MathHelper.getVerticalConvergence(x, m, c) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n\nGet the vertical convergence point from a X position\n\n**Kind**: static method of [\u003ccode\u003eMathHelper\u003c/code\u003e](#module_MathHelper)\n\n| Param | Type                |\n| ----- | ------------------- |\n| x     | \u003ccode\u003enumber\u003c/code\u003e |\n| m     | \u003ccode\u003enumber\u003c/code\u003e |\n| c     | \u003ccode\u003enumber\u003c/code\u003e |\n\n\u003ca name=\"module_MathHelper.getLineParams\"\u003e\u003c/a\u003e\n\n### MathHelper.getLineParams(x1, y1, x2, y2) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n\nReturn line parameters\n\n**Kind**: static method of [\u003ccode\u003eMathHelper\u003c/code\u003e](#module_MathHelper)\n\n| Param | Type                |\n| ----- | ------------------- |\n| x1    | \u003ccode\u003enumber\u003c/code\u003e |\n| y1    | \u003ccode\u003enumber\u003c/code\u003e |\n| x2    | \u003ccode\u003enumber\u003c/code\u003e |\n| y2    | \u003ccode\u003enumber\u003c/code\u003e |\n\n\u003ca name=\"module_MathHelper.getParallelLine\"\u003e\u003c/a\u003e\n\n### MathHelper.getParallelLine(line, point) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n\nGet parallel line parameters\n\n**Kind**: static method of [\u003ccode\u003eMathHelper\u003c/code\u003e](#module_MathHelper)\n\n| Param | Type                |\n| ----- | ------------------- |\n| line  | \u003ccode\u003enumber\u003c/code\u003e |\n| point | \u003ccode\u003ePoint\u003c/code\u003e  |\n\n\u003ca name=\"module_MathHelper.getDistanceToLine\"\u003e\u003c/a\u003e\n\n### MathHelper.getDistanceToLine(line, point) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n\nGet the distance to a line parameters\n\n**Kind**: static method of [\u003ccode\u003eMathHelper\u003c/code\u003e](#module_MathHelper)\n\n| Param | Type                |\n| ----- | ------------------- |\n| line  | \u003ccode\u003eObject\u003c/code\u003e |\n| point | \u003ccode\u003ePoint\u003c/code\u003e  |\n\n\u003ca name=\"module_MathHelper.getProjectedPoint\"\u003e\u003c/a\u003e\n\n### MathHelper.getProjectedPoint(line, point) ⇒ \u003ccode\u003ePoint\u003c/code\u003e\n\nGet a projected point\n\n**Kind**: static method of [\u003ccode\u003eMathHelper\u003c/code\u003e](#module_MathHelper)\n\n| Param | Type                |\n| ----- | ------------------- |\n| line  | \u003ccode\u003eObject\u003c/code\u003e |\n| point | \u003ccode\u003ePoint\u003c/code\u003e  |\n\n\u003ca name=\"module_MathHelper.getMassCenter\"\u003e\u003c/a\u003e\n\n### MathHelper.getMassCenter(p1, p2, p3, p4) ⇒ \u003ccode\u003ePoint\u003c/code\u003e\n\nGet the center of four points\n\n**Kind**: static method of [\u003ccode\u003eMathHelper\u003c/code\u003e](#module_MathHelper)\n\n| Param | Type               |\n| ----- | ------------------ |\n| p1    | \u003ccode\u003ePoint\u003c/code\u003e |\n| p2    | \u003ccode\u003ePoint\u003c/code\u003e |\n| p3    | \u003ccode\u003ePoint\u003c/code\u003e |\n| p4    | \u003ccode\u003ePoint\u003c/code\u003e |\n\n\u003ca name=\"module_PerspectiveGrid\"\u003e\u003c/a\u003e\n\n## PerspectiveGrid\n\n- [PerspectiveGrid](#module_PerspectiveGrid)\n  - [PerspectiveGrid](#exp_module_PerspectiveGrid--PerspectiveGrid) ⏏\n    - [new PerspectiveGrid(units, [squares])](#new_module_PerspectiveGrid--PerspectiveGrid_new)\n    - [.init(tl, tr, br, bl)](#module_PerspectiveGrid--PerspectiveGrid+init)\n    - [.draw(context)](#module_PerspectiveGrid--PerspectiveGrid+draw)\n    - [.update()](#module_PerspectiveGrid--PerspectiveGrid+update)\n    - [.getQuadAt(column, row)](#module_PerspectiveGrid--PerspectiveGrid+getQuadAt) ⇒ \u003ccode\u003eArray.\u0026lt;Point\u0026gt;\u003c/code\u003e\n    - [.getCenterAt(column, row)](#module_PerspectiveGrid--PerspectiveGrid+getCenterAt) ⇒ \u003ccode\u003ePoint\u003c/code\u003e\n    - [.drawLines(context)](#module_PerspectiveGrid--PerspectiveGrid+drawLines)\n    - [.drawSquares(context)](#module_PerspectiveGrid--PerspectiveGrid+drawSquares)\n    - [.drawPoint(context, point, radius, color)](#module_PerspectiveGrid--PerspectiveGrid+drawPoint)\n    - [.\\_getHorizon(vVanishing, hVanishing)](#module_PerspectiveGrid--PerspectiveGrid+_getHorizon) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n\n\u003ca name=\"exp_module_PerspectiveGrid--PerspectiveGrid\"\u003e\u003c/a\u003e\n\n### PerspectiveGrid ⏏\n\nTwo point perspective grid on canvas.\n\nNote: Does not work correctly when there is only one vanishing point.\n\n**Kind**: Exported class\n\u003ca name=\"new_module_PerspectiveGrid--PerspectiveGrid_new\"\u003e\u003c/a\u003e\n\n#### new PerspectiveGrid(units, [squares])\n\nCreates an instance of PerspectiveGrid.\n\n| Param     | Type                                                     | Description                                           |\n| --------- | -------------------------------------------------------- | ----------------------------------------------------- |\n| units     | \u003ccode\u003enumber\u003c/code\u003e \\| \u003ccode\u003eArray.\u0026lt;number\u0026gt;\u003c/code\u003e | Number of rows and columns (unit or [rows, columns]). |\n| [squares] | \u003ccode\u003eArray.\u0026lt;Point\u0026gt;\u003c/code\u003e                         | Highlighted squares in the grid                       |\n\n\u003ca name=\"module_PerspectiveGrid--PerspectiveGrid+init\"\u003e\u003c/a\u003e\n\n#### perspectiveGrid.init(tl, tr, br, bl)\n\nReset the corners (clockwise starting from top left)\n\n**Kind**: instance method of [\u003ccode\u003ePerspectiveGrid\u003c/code\u003e](#exp_module_PerspectiveGrid--PerspectiveGrid)\n\n| Param | Type               | Description         |\n| ----- | ------------------ | ------------------- |\n| tl    | \u003ccode\u003ePoint\u003c/code\u003e | Top left corner     |\n| tr    | \u003ccode\u003ePoint\u003c/code\u003e | Top right corner    |\n| br    | \u003ccode\u003ePoint\u003c/code\u003e | Bottom right corner |\n| bl    | \u003ccode\u003ePoint\u003c/code\u003e | Bottom left corner  |\n\n\u003ca name=\"module_PerspectiveGrid--PerspectiveGrid+draw\"\u003e\u003c/a\u003e\n\n#### perspectiveGrid.draw(context)\n\nDraw the grid in the instance context\n\n**Kind**: instance method of [\u003ccode\u003ePerspectiveGrid\u003c/code\u003e](#exp_module_PerspectiveGrid--PerspectiveGrid)\n\n| Param   | Type                                  | Description                     |\n| ------- | ------------------------------------- | ------------------------------- |\n| context | \u003ccode\u003eCanvasRenderingContext2D\u003c/code\u003e | The context to draw the grid in |\n\n\u003ca name=\"module_PerspectiveGrid--PerspectiveGrid+update\"\u003e\u003c/a\u003e\n\n#### perspectiveGrid.update()\n\nUpdate grid segments\n\n**Kind**: instance method of [\u003ccode\u003ePerspectiveGrid\u003c/code\u003e](#exp_module_PerspectiveGrid--PerspectiveGrid)\n\u003ca name=\"module_PerspectiveGrid--PerspectiveGrid+getQuadAt\"\u003e\u003c/a\u003e\n\n#### perspectiveGrid.getQuadAt(column, row) ⇒ \u003ccode\u003eArray.\u0026lt;Point\u0026gt;\u003c/code\u003e\n\nGet the four vertices of a point in grid\n\n**Kind**: instance method of [\u003ccode\u003ePerspectiveGrid\u003c/code\u003e](#exp_module_PerspectiveGrid--PerspectiveGrid)\n\n| Param  | Type                |\n| ------ | ------------------- |\n| column | \u003ccode\u003enumber\u003c/code\u003e |\n| row    | \u003ccode\u003enumber\u003c/code\u003e |\n\n\u003ca name=\"module_PerspectiveGrid--PerspectiveGrid+getCenterAt\"\u003e\u003c/a\u003e\n\n#### perspectiveGrid.getCenterAt(column, row) ⇒ \u003ccode\u003ePoint\u003c/code\u003e\n\nGet the center point from grid unit to pixel eg. (1, 1) is the first top left point\n\n**Kind**: instance method of [\u003ccode\u003ePerspectiveGrid\u003c/code\u003e](#exp_module_PerspectiveGrid--PerspectiveGrid)\n\n| Param  | Type                |\n| ------ | ------------------- |\n| column | \u003ccode\u003enumber\u003c/code\u003e |\n| row    | \u003ccode\u003enumber\u003c/code\u003e |\n\n\u003ca name=\"module_PerspectiveGrid--PerspectiveGrid+drawLines\"\u003e\u003c/a\u003e\n\n#### perspectiveGrid.drawLines(context)\n\nActually draw the lines (vertical and horizontal) in the context\n\n**Kind**: instance method of [\u003ccode\u003ePerspectiveGrid\u003c/code\u003e](#exp_module_PerspectiveGrid--PerspectiveGrid)\n\n| Param   | Type                                  | Description                     |\n| ------- | ------------------------------------- | ------------------------------- |\n| context | \u003ccode\u003eCanvasRenderingContext2D\u003c/code\u003e | The context to draw the grid in |\n\n\u003ca name=\"module_PerspectiveGrid--PerspectiveGrid+drawSquares\"\u003e\u003c/a\u003e\n\n#### perspectiveGrid.drawSquares(context)\n\nDraw highlighted squares in the grid\n\n**Kind**: instance method of [\u003ccode\u003ePerspectiveGrid\u003c/code\u003e](#exp_module_PerspectiveGrid--PerspectiveGrid)\n\n| Param   | Type                                  | Description                     |\n| ------- | ------------------------------------- | ------------------------------- |\n| context | \u003ccode\u003eCanvasRenderingContext2D\u003c/code\u003e | The context to draw the grid in |\n\n\u003ca name=\"module_PerspectiveGrid--PerspectiveGrid+drawPoint\"\u003e\u003c/a\u003e\n\n#### perspectiveGrid.drawPoint(context, point, radius, color)\n\nDraw a single point in the grid useful for debug purpose\n\n**Kind**: instance method of [\u003ccode\u003ePerspectiveGrid\u003c/code\u003e](#exp_module_PerspectiveGrid--PerspectiveGrid)\n\n| Param   | Type                                  | Description                     |\n| ------- | ------------------------------------- | ------------------------------- |\n| context | \u003ccode\u003eCanvasRenderingContext2D\u003c/code\u003e | The context to draw the grid in |\n| point   | \u003ccode\u003ePoint\u003c/code\u003e                    |                                 |\n| radius  | \u003ccode\u003enumber\u003c/code\u003e                   |                                 |\n| color   | \u003ccode\u003estring\u003c/code\u003e                   |                                 |\n\n\u003ca name=\"module_PerspectiveGrid--PerspectiveGrid+_getHorizon\"\u003e\u003c/a\u003e\n\n#### perspectiveGrid.\\_getHorizon(vVanishing, hVanishing) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n\nGet a line parallel to the horizon\n\n**Kind**: instance method of [\u003ccode\u003ePerspectiveGrid\u003c/code\u003e](#exp_module_PerspectiveGrid--PerspectiveGrid)\n\n| Param      | Type               |\n| ---------- | ------------------ |\n| vVanishing | \u003ccode\u003ePoint\u003c/code\u003e |\n| hVanishing | \u003ccode\u003ePoint\u003c/code\u003e |\n\n\u003ca name=\"module_Point\"\u003e\u003c/a\u003e\n\n## Point\n\n- [Point](#module_Point)\n  - [Point](#exp_module_Point--Point) ⏏\n    - [new Point(x, y)](#new_module_Point--Point_new)\n    - [.isInList(list)](#module_Point--Point+isInList) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n\n\u003ca name=\"exp_module_Point--Point\"\u003e\u003c/a\u003e\n\n### Point ⏏\n\nAn object that defines a Point\n\n**Kind**: Exported class\n\u003ca name=\"new_module_Point--Point_new\"\u003e\u003c/a\u003e\n\n#### new Point(x, y)\n\n| Param | Type                | Description  |\n| ----- | ------------------- | ------------ |\n| x     | \u003ccode\u003enumber\u003c/code\u003e | x coordinate |\n| y     | \u003ccode\u003enumber\u003c/code\u003e | y coordinate |\n\n\u003ca name=\"module_Point--Point+isInList\"\u003e\u003c/a\u003e\n\n#### point.isInList(list) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n\nCheck if a point is in a list of points\n\n**Kind**: instance method of [\u003ccode\u003ePoint\u003c/code\u003e](#exp_module_Point--Point)\n\n| Param | Type                             | Description     |\n| ----- | -------------------------------- | --------------- |\n| list  | \u003ccode\u003eArray.\u0026lt;Point\u0026gt;\u003c/code\u003e | Array of Points |\n\n\u003ca name=\"module_Segment\"\u003e\u003c/a\u003e\n\n## Segment\n\n- [Segment](#module_Segment)\n  - [Segment](#exp_module_Segment--Segment) ⏏\n    - [new Segment(p1, p1)](#new_module_Segment--Segment_new)\n    - [.intersect(segment)](#module_Segment--Segment+intersect) ⇒ \u003ccode\u003ePoint\u003c/code\u003e\n\n\u003ca name=\"exp_module_Segment--Segment\"\u003e\u003c/a\u003e\n\n### Segment ⏏\n\nAn object with two points that defines a segment\n\n**Kind**: Exported class\n\u003ca name=\"new_module_Segment--Segment_new\"\u003e\u003c/a\u003e\n\n#### new Segment(p1, p1)\n\n| Param | Type               | Description  |\n| ----- | ------------------ | ------------ |\n| p1    | \u003ccode\u003ePoint\u003c/code\u003e | First point  |\n| p1    | \u003ccode\u003ePoint\u003c/code\u003e | Second point |\n\n\u003ca name=\"module_Segment--Segment+intersect\"\u003e\u003c/a\u003e\n\n#### segment.intersect(segment) ⇒ \u003ccode\u003ePoint\u003c/code\u003e\n\nGet intersection of two segments\n\n**Kind**: instance method of [\u003ccode\u003eSegment\u003c/code\u003e](#exp_module_Segment--Segment)\n\n| Param   | Type                 |\n| ------- | -------------------- |\n| segment | \u003ccode\u003eSegment\u003c/code\u003e |\n\n\u003c!-- api-end --\u003e\n\n## License\n\nMIT. See [license file](https://github.com/dmnsgn/perspective-grid/blob/main/LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmnsgn%2Fperspective-grid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmnsgn%2Fperspective-grid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmnsgn%2Fperspective-grid/lists"}