{"id":17689898,"url":"https://github.com/cdaein/geom","last_synced_at":"2026-02-02T04:02:32.487Z","repository":{"id":61828596,"uuid":"555507389","full_name":"cdaein/geom","owner":"cdaein","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-27T03:14:51.000Z","size":1931,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-23T04:51:26.617Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/cdaein.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2022-10-21T18:11:22.000Z","updated_at":"2025-10-12T23:56:31.000Z","dependencies_parsed_at":"2024-01-16T23:18:03.399Z","dependency_job_id":"7f6c6373-2ab7-49ef-a326-fdc24f9c285a","html_url":"https://github.com/cdaein/geom","commit_stats":{"total_commits":59,"total_committers":2,"mean_commits":29.5,"dds":0.288135593220339,"last_synced_commit":"b50b80f9e356d90d086a3524955efca640caab25"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cdaein/geom","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdaein%2Fgeom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdaein%2Fgeom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdaein%2Fgeom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdaein%2Fgeom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cdaein","download_url":"https://codeload.github.com/cdaein/geom/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdaein%2Fgeom/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29004695,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-02T01:32:03.847Z","status":"online","status_checked_at":"2026-02-02T02:00:07.448Z","response_time":58,"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":[],"created_at":"2024-10-24T11:49:15.278Z","updated_at":"2026-02-02T04:02:32.473Z","avatar_url":"https://github.com/cdaein.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @daeinc/geom\n\nA collection of gemetry-related functions. Breaking changes expected in the future.\n\n## Installation\n\n```\nnpm i @daeinc/geom\n```\n\nthen,\n\n```js\nimport { blendPath, ... } from \"@daeinc/geom\";\n```\n\n## CDN\n\n```js\nimport { blendPath, ... } from \"https://cdn.jsdelivr.net/npm/@daeinc/geom/dist/geom.esm.js\"\n```\n\n## Types\n\n```ts\ntype Pt = number[];\ntype Pts = number[][];\ntype GenericObject = Record\u003cstring, any\u003e;\n```\n\nThree custom types are used.\n\n## Functions\n\n### blendPath\n\n```ts\nconst blendPath: (\n  path1: Pts,\n  path2: Pts,\n  numBlends: number,\n  guidePath?: Pts,\n) =\u003e number[][][];\n```\n\nInterpolates two paths to create in-between paths. `numBlends` does not count the two original paths. In other words, the two original paths are not included in the return array. `guidePath` parameter is not yet implemented.\n\n### createShapeFunc\n\n```ts\nconst createShapeFunc: (\n  pts: Pts,\n  anchor?: Pt,\n) =\u003e (x: number, y: number, w: number, h: number) =\u003e Pts;\n```\n\n### dist\n\n```ts\nconst dist: (pt1: Pt, pt2: Pt) =\u003e number;\n```\n\nReturns a distance between two points.\n\n### distSq\n\n```ts\nconst distSq: (pt1: Pt, pt2: Pt) =\u003e number;\n```\n\nReturns a squared distance between two points. There's another version in `@daeinc/math` that takes `number` arguments.\n\n### extrudePath\n\n```ts\nconst extrudePath: (\n  path: Pts,\n  numPointsToExtrude: number,\n  offset: Pt,\n  mode?: \"start\" | \"end\" | \"both\",\n  shapeFunc?: () =\u003e Pts,\n) =\u003e number[][];\n```\n\nExtrudes a path in 2d space.\n\n### generateSmoothPath\n\n```ts\nconst generateSmoothPath: (pts: Pts, smoothFactor: number) =\u003e number[][];\n```\n\nGenerates extra points for smooth corners of path. Use with `drawSmoothPath()` from another package, `@daeinc/canvas`\n\n### getAngleBetween\n\n```ts\nconst getAngleBetween: (pt1: Pt, pt2: Pt) =\u003e number;\n```\n\nGet angle between two points using `Math.atan2()`. Return value is between -pi and pi. `pt2 - pt1` is the order of subtraction.\n\n### getPathLength\n\n```ts\nconst getPathLength: (path: Pts) =\u003e number;\n```\n\nReturns the total length of path\n\n### getPositiveAngleBetween\n\n```ts\nconst getPositiveAngleBetween: (pt1: Pt, pt2: Pt) =\u003e number;\n```\n\nReturn value is between 0 and 2pi.\n\n### getSegmentLengths\n\n```ts\nconst getSegmentLengths: (pts: Pts) =\u003e number[];\n```\n\nReturns an array with each segment length (distance between points).\n\n### interpolateArray\n\n```ts\nconst interpolateArray: (\n  arrStart: number[],\n  arrTarget: number[],\n  t: number,\n) =\u003e number[];\n```\n\n### interpolatePath\n\n```ts\nconst interpolatePath: (\n  pathStart: Pts,\n  pathTarget: Pts,\n  t: number,\n) =\u003e number[][];\n```\n\nInterpolates between two number arrays. Usually used for path data of `[x, y]`.\n\n### interpolateObject\n\n```ts\nconst interpolateObject: (\n  objStart: GenericObject,\n  objTarget: GenericObject,\n  t: number,\n) =\u003e GenericObject;\n```\n\nInterpolates between two objects formatted `{ string: number }`. For example, `{ x: 10, y: 20 }`.\n\n### interpolate\n\n```ts\nconst interpolate: \u003cT\u003e(\n  start: T,\n  target: T,\n  t: number,\n) =\u003e number | GenericObject | T;\n```\n\nInterpolates `number`, `number[]`, `number[][]` or generic object.\n\n### projectPointOnLine\n\n```ts\nconst projectPointOnLine: (pt: Pt, line: Pts) =\u003e Pt;\n```\n\nProjects a point on a line.\n\n### reflectPoint\n\n```ts\nconst reflectPoint: (pt: Pt, axis: Pt | Pts) =\u003e Pt;\n```\n\nReflects a point on another point or a line.\n\n### reflectPath\n\n```ts\nconst reflectPath: (pts: Pts, axis: Pt | Pts) =\u003e Pts;\n```\n\nReflects a path either on a point or a line.\n\n### scalePoint\n\n```ts\nconst scalePoint: (pt: Pt, size: Pt) =\u003e Pt;\n```\n\nScales a single point.\n\n### scalePath\n\n```ts\nconst scalePath: (path: Pts, size: Pt) =\u003e Pts;\n```\n\nTakes in normalized path data and returns `[ x, y ]` that is scaled to size, `[ width, height ]`.\n\n## To Dos\n\n- reconcile the use of both `Float32Array`(`gl-vec2`) and regular array\n- add Canvas mock tests\n  - https://github.com/hustcc/jest-canvas-mock\n  - https://github.com/americanexpress/jest-image-snapshot/\n  - https://yonatankra.com/how-to-test-html5-canvas-with-jest/\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdaein%2Fgeom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcdaein%2Fgeom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdaein%2Fgeom/lists"}