{"id":26417089,"url":"https://github.com/siarheihuzarevich/foblex2D","last_synced_at":"2025-03-18T01:06:12.182Z","repository":{"id":257031324,"uuid":"857141760","full_name":"siarheihuzarevich/foblex2D","owner":"siarheihuzarevich","description":"An Angular library for 2D geometric computations, providing classes and utilities for manipulating points, lines, vectors, rectangles, arcs, and transformations","archived":false,"fork":false,"pushed_at":"2025-03-07T21:38:01.000Z","size":287,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-14T05:23:20.719Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/siarheihuzarevich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-09-13T22:24:47.000Z","updated_at":"2025-03-09T00:19:00.000Z","dependencies_parsed_at":"2024-09-14T12:51:41.418Z","dependency_job_id":"fb315363-1a2c-4c54-8e5d-4dcceb989250","html_url":"https://github.com/siarheihuzarevich/foblex2D","commit_stats":null,"previous_names":["siarheihuzarevich/foblex2d"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siarheihuzarevich%2Ffoblex2D","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siarheihuzarevich%2Ffoblex2D/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siarheihuzarevich%2Ffoblex2D/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siarheihuzarevich%2Ffoblex2D/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/siarheihuzarevich","download_url":"https://codeload.github.com/siarheihuzarevich/foblex2D/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244135908,"owners_count":20403798,"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":"2025-03-18T01:01:42.170Z","updated_at":"2025-03-18T01:06:12.177Z","avatar_url":"https://github.com/siarheihuzarevich.png","language":"TypeScript","funding_links":[],"categories":["Framework Interoperability"],"sub_categories":["External Integration"],"readme":"# Foblex2D\n\nAn Angular library for 2D geometric computations, providing classes and utilities for manipulating points, lines, vectors, rectangles, arcs, and transformations. \nUsed in [Foblex Flow](https://flow.foblex.com) for 2D geometric operations.\n\n## Overview\n\nThe Foblex2D library is designed to simplify 2D geometric operations in TypeScript and Angular applications. It offers a rich set of classes and utility functions for:\n\n- **Geometric Primitives**: Points, Lines, Vectors, Rectangles, Arcs, and Rounded Rectangles.\n- **Geometric Calculations**: Distance, angle, intersection detection, and transformations.\n- **Transformations**: Handling position, scaling, and rotation transformations.\n- **Intersection Detection**: Finding intersections between line segments and various shapes, including rounded rectangles and arcs.\n\nWhether you’re building graphical editors, games, data visualization tools, or any application that requires precise 2D geometric computations, Foblex2D provides the tools you need.\n\n## Installation\n\nInstall the library via npm:\n\n```bash\n  npm install @foblex/2D\n```\n## Usage\n\n### Working with Points\n\nCreate and manipulate points:\n\n```typescript\nimport { Point, PointExtensions } from '@foblex/2D';\n\n// Using the Point class\nconst pointA = new Point(10, 20);\nconst pointB = new Point(30, 40);\n\n// Using PointExtensions for utility functions\nconst sumPoint = pointA.add(pointB);\nconst distance = PointExtensions.distance(pointA, pointB);\n\nconsole.log(`Sum Point: (${sumPoint.x}, ${sumPoint.y})`);\nconsole.log(`Distance between points: ${distance}`);\n```\n\n### Working with Lines\n\nCreate and manipulate lines:\n\n```typescript\nimport { Line, LineExtensions } from '@foblex/2D';\n\nconst point1 = new Point(0, 0);\nconst point2 = new Point(10, 10);\n\nconst line = new Line(point1, point2);\n\n// Calculate the length of the line\nconst length = LineExtensions.hypotenuse(line);\n\nconsole.log(`Line length: ${length}`);\n```\n\n### Vector Operations\n\nPerform vector calculations:\n\n```typescript\nimport { VectorExtensions } from '@foblex/2D';\n\nconst vector1 = VectorExtensions.initialize(1, 0);\nconst vector2 = VectorExtensions.initialize(0, 1);\n\n// Calculate the angle between two vectors\nconst angleRadians = VectorExtensions.angle(vector1, vector2);\nconst angleDegrees = (angleRadians * 180) / Math.PI;\n\nconsole.log(`Angle between vectors: ${angleDegrees} degrees`);\n```\n\n### Working with Rectangles\n\nCreate and manipulate rectangles:\n\n```typescript\nimport { RectExtensions, IRect, Point } from '@foblex/2D';\n\n// Initialize a rectangle\nconst rect = RectExtensions.initialize(0, 0, 100, 50);\n\n// Check if a point is inside the rectangle\nconst point = new Point(50, 25);\nconst isInside = RectExtensions.isIncludePoint(rect, point);\n\nconsole.log(`Point is inside rectangle: ${isInside}`);\n```\n\n### Handling Transformations\n\nWork with transformations:\n\n```typescript\nimport { ITransformModel, TransformModelExtensions } from '@foblex/2D';\n\nconst transform = TransformModelExtensions.default();\ntransform.position = { x: 100, y: 50 };\ntransform.scale = 2;\n\n// Get the transformation matrix string\nconst transformString = TransformModelExtensions.toString(transform);\n\nconsole.log(`Transform Matrix: ${transformString}`);\n```\n\n### Finding Intersections\n\nDetect intersections between lines and shapes:\n\n```typescript\nimport { IntersectionFinder, RoundedRect, Point } from '@foblex/2D';\n\nconst fromPoint = new Point(0, 0);\nconst toPoint = new Point(150, 150);\n\nconst roundedRect = new RoundedRect(50, 50, 100, 100, 20, 20, 20, 20);\n\nconst intersections = IntersectionFinder.getIntersections(fromPoint, toPoint, roundedRect);\n\nif (intersections.length \u003e 0) {\n  intersections.forEach((point, index) =\u003e {\n    console.log(`Intersection ${index + 1}: (${point.x}, ${point.y})`);\n  });\n} else {\n  console.log('No intersections found.');\n}\n```\n\n## License\n\nThis project is licensed under the MIT License.\n\nBy integrating Foblex2D into your Angular projects, you can simplify complex 2D geometric computations, enhance performance, and focus on building feature-rich applications.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiarheihuzarevich%2Ffoblex2D","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiarheihuzarevich%2Ffoblex2D","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiarheihuzarevich%2Ffoblex2D/lists"}