{"id":13547603,"url":"https://github.com/mattdesl/polyline-normals","last_synced_at":"2025-04-05T19:10:43.019Z","repository":{"id":23870499,"uuid":"27249200","full_name":"mattdesl/polyline-normals","owner":"mattdesl","description":"gets miter normals for a 2D polyline","archived":false,"fork":false,"pushed_at":"2023-11-27T04:31:01.000Z","size":180,"stargazers_count":136,"open_issues_count":3,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T07:50:34.063Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/mattdesl.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2014-11-28T02:47:38.000Z","updated_at":"2025-02-12T12:24:53.000Z","dependencies_parsed_at":"2024-06-18T14:06:44.514Z","dependency_job_id":null,"html_url":"https://github.com/mattdesl/polyline-normals","commit_stats":{"total_commits":15,"total_committers":1,"mean_commits":15.0,"dds":0.0,"last_synced_commit":"d37f6f6919e2963b70a54017c397d98c02207312"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattdesl%2Fpolyline-normals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattdesl%2Fpolyline-normals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattdesl%2Fpolyline-normals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattdesl%2Fpolyline-normals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattdesl","download_url":"https://codeload.github.com/mattdesl/polyline-normals/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247386262,"owners_count":20930619,"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-08-01T12:00:58.631Z","updated_at":"2025-04-05T19:10:42.994Z","avatar_url":"https://github.com/mattdesl.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","etc"],"sub_categories":[],"readme":"# polyline-normals\n\n[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)\n\n![img](http://i.imgur.com/UP2Fq12.png)\n\nComputes the normals of a polyline, using miter joins where multiple segments meet.  This is mainly useful to expand thick lines in a vertex shader on the GPU. \n\n```js\nvar getNormals = require('polyline-normals')\n\n//a triangle\nvar path = [ [0, 122], [0, 190], [90, 190] ]\n\n//get the normals as a closed loop\nvar normals = getNormals(path, true)\n\n//now draw our thick line in 2D/3D/etc\n```\n\nSee [the 2d test](test-2d.js) for an example of how these lines would be extruded. \n\nFor more complex line joins and end caps, see [extrude-polyline](https://nodei.co/npm/extrude-polyline/) (which builds an indexed mesh). \n\n## Shader Example\n\nFor an example of how to use this within a shader, see [three-line-2d](https://nodei.co/npm/three-line-2d/).\n\n## Usage\n\n[![NPM](https://nodei.co/npm/polyline-normals.png)](https://nodei.co/npm/polyline-normals/)\n\n#### `normals(path[, closed])`\n\nFor the given path, produces a new array of the same length with normal information for each point. The data contains a normal, `[nx, ny]` and the length of the miter (default to 1.0 where no join occurs). \n\n```js\n[ \n    [ [nx, ny], miterLength ],\n    [ [nx, ny], miterLength ]\n]\n```\n\nIf `closed` is true, it assumes a segment will be drawn from the last point to the first point, and adjusts those normals accordingly.\n\n## License\n\nMIT, see [LICENSE.md](http://github.com/mattdesl/polyline-normals/blob/master/LICENSE.md) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattdesl%2Fpolyline-normals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattdesl%2Fpolyline-normals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattdesl%2Fpolyline-normals/lists"}