{"id":22870552,"url":"https://github.com/layerex/beizer-curves","last_synced_at":"2025-03-31T11:26:28.681Z","repository":{"id":57414597,"uuid":"427455806","full_name":"Layerex/beizer-curves","owner":"Layerex","description":"A python library for generating beizer curves.","archived":false,"fork":false,"pushed_at":"2021-11-12T19:03:53.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T06:19:54.693Z","etag":null,"topics":["beizer","beizer-curves","mouse-movement"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Layerex.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":"2021-11-12T18:14:58.000Z","updated_at":"2021-11-12T19:06:57.000Z","dependencies_parsed_at":"2022-09-10T04:03:52.044Z","dependency_job_id":null,"html_url":"https://github.com/Layerex/beizer-curves","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Layerex%2Fbeizer-curves","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Layerex%2Fbeizer-curves/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Layerex%2Fbeizer-curves/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Layerex%2Fbeizer-curves/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Layerex","download_url":"https://codeload.github.com/Layerex/beizer-curves/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246460402,"owners_count":20781112,"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":["beizer","beizer-curves","mouse-movement"],"created_at":"2024-12-13T13:14:57.065Z","updated_at":"2025-03-31T11:26:28.662Z","avatar_url":"https://github.com/Layerex.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# beizer-curves\n\nA python library for generating beizer curves.\n\n## Installation\n\n```sh\npip install beizer-curves\n```\n\n## Usage\n\n```python\ndef beizer_curve(\n    points,\n    output_points_count: int,\n    destructive: bool = False,\n    dtype: np.dtype = np.int64,\n):\n```\n\nGenerate a beizer curve.\n\n- `points` - Knots in format: `[[x1, x2, ..., xn], [y1, y2, ..., yn], [z1, z2, ..., zn]]`.\n- `output_points_count` - How many points of the curve to generate.\n- `destructive` - Allow function to modify `points` array. Don't set to true, if you want to use `points` array later.\n- `dtype` - dtype of array of returned points of the curve.\n\nPoints of a curve are returned in format: `[[x1, x2, ..., xn], [y1, y2, ..., yn], [z1, z2, ..., zn]]`, where n is `output_points_count`.\n\n```python\ndef random_beizer_curve(\n    start_point,\n    end_point,\n    output_points_count: int,\n    random_points_count: int = 1,\n    point_spread: float = 1,\n    noise_max_offset: float = 0,\n    noise_rate: float = 0.5,\n    dtype=np.int64,\n    return_forming_points: bool = False,\n):\n```\n\nGenerate a random beizer curve, which starts at start_point and ends at end_point.\n\n- `start_point`, `end_point` - coordinates of start and end points of curve in format `[x, y, z, ...]`.\n- `output_points_count` - How many points of the curve to generate.\n\n  ```python\n  if output_points_count \u003c 0:\n       output_points_count = math.ceil(distance / -output_points_count)\n  ```\n\n  Where `distance` is distance between start and end.\n\n- `random_points_count` - How many knots to generate.\n- `point_spread` - A scale of a rectangular figure with corners of start_point and end_point, in bounds of which random knots are generated. Has to be \u003e 0.\n- `noise_max_offset` - Max offset of a curve point.\n\n  ```python\n  if output_points_count \u003c 0:\n      output_points_count = math.ceil(distance / -output_points_count)\n  ```\n\n  Where `distance` is distance between start and end.\n\n- `noise_rate` - A part of curve points to apply noise offset to. Has to belong to [0; 1].\n- `dtype` - dtype array of returned points of the curve.\n- `return_forming_points` - `return points, curve if return_forming_points else curve`, where `points` are randomly generated knots\n\n## Usage example\n\n```python\nimport random\n\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nfrom beizer_curves import *\n\ndef plot_curve(points_count, i):\n    start = [random.randrange(1, 2000), random.randrange(1, 2000)]\n    noise = -200 * i\n    end = [random.randrange(1, 2000), random.randrange(1, 2000)]\n    points, curve = random_beizer_curve(\n        start,\n        end,\n        output_points_count=50,\n        random_points_count=points_count,\n        noise_max_offset=noise,\n        noise_rate=0.25,\n        dtype=np.float64,\n        return_forming_points=True,\n    )\n\n    fig = plt.figure()\n    plt.axis(\"equal\")\n    plt.scatter(curve[0], curve[1])\n    plt.scatter(points[0], points[1], color='red')\n    fig.savefig(f\"example_{points_count}_{i + 1}.png\")\n```\n\n## Example curves\n\u003cimg src=\"https://files.catbox.moe/2blh6b.png\"\u003e\n\u003cimg src=\"https://files.catbox.moe/sketjb.png\"\u003e\n\u003cimg src=\"https://files.catbox.moe/t1k34o.png\"\u003e\n\u003cimg src=\"https://files.catbox.moe/fj8c4g.png\"\u003e\n\u003cimg src=\"https://files.catbox.moe/p3swwz.png\"\u003e\n\u003cimg src=\"https://files.catbox.moe/myjdoz.png\"\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flayerex%2Fbeizer-curves","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flayerex%2Fbeizer-curves","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flayerex%2Fbeizer-curves/lists"}