{"id":17302325,"url":"https://github.com/coriolinus/lerp-rs","last_synced_at":"2025-04-14T12:50:53.875Z","repository":{"id":54953404,"uuid":"65012251","full_name":"coriolinus/lerp-rs","owner":"coriolinus","description":"Linear interpolation and extrapolation over numeric types","archived":false,"fork":false,"pushed_at":"2023-06-17T22:55:12.000Z","size":673,"stargazers_count":5,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T01:53:40.890Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://coriolinus.github.io/lerp-rs/","language":"Rust","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/coriolinus.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-05T11:01:24.000Z","updated_at":"2023-11-06T08:58:07.000Z","dependencies_parsed_at":"2022-08-14T07:20:37.303Z","dependency_job_id":null,"html_url":"https://github.com/coriolinus/lerp-rs","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coriolinus%2Flerp-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coriolinus%2Flerp-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coriolinus%2Flerp-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coriolinus%2Flerp-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coriolinus","download_url":"https://codeload.github.com/coriolinus/lerp-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248530272,"owners_count":21119586,"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-10-15T11:47:12.352Z","updated_at":"2025-04-14T12:50:53.850Z","avatar_url":"https://github.com/coriolinus.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lerp\n\n[![Build Status](https://travis-ci.org/coriolinus/lerp-rs.svg?branch=master)](https://travis-ci.org/coriolinus/lerp-rs)\n\nLinear interpolation and iteration, automatically implemented over most\nfloat-compatible types.\n\nJust need to know what's halfway between three and five?\n\n```rust\nuse lerp::Lerp;\n\nassert_eq!(3.0.lerp(5.0, 0.5), 4.0);\n```\n\nWant to iterate across some points in that range?\n\n```rust\n// bring the trait into scope\nuse lerp::LerpIter;\n\n// iterate and produce four items evenly spaced between 3.0 and 5.0\n// note that the default, open iterator does not include both endpoints\n// this makes chaining lerping iterators simpler\nlet items: Vec\u003c_\u003e = 3.0_f64.lerp_iter(5.0, 4).collect();\nassert_eq!(vec![3.0, 3.5, 4.0, 4.5], items);\n\n// closed iterators return both ends\nassert_eq!(vec![3.0, 5.0], 3.0.lerp_iter_closed(5.0, 2).collect::\u003cVec\u003c_\u003e\u003e());\n```\n\nOf course, the real benefit is that it's derivation is broad enough that it also\ncovers types such as `num::Complex\u003cT\u003e`. If you have an array-processing library,\nand the arrays are `T: Add\u003cOutput = T\u003e + Mul\u003cF: Float, Output = T\u003e`, it'll just\nwork for them as well.\n\n## Deriving `Lerp`\n\nAs well as working for individual float values, the crate also provides a derive\nmacro, available with the `derive` feature, which will be able to generate an\nimplementation automatically.\n\nThis derive implementation will lerp each field of the struct independently\nand assumes a generic implementation of Lerp over `Float` types. If any\nof the fields is generic only over one of the float values (f32, f64) that\ncan be specified by the `#[lerp(f32)]` or `#[lerp(f64)]` attributes respectively.\n\nIf you would like for the lerp implementation to ignore a field (or if it does\nnot derive lerp) you can use the `#[lerp(skip)]` or `#[lerp(ignore)]` attributes\nwhich will produce the value, untouched from the left value.\n\nNot all types are supported in this derive macro. See [the github issue] for\ndiscussion and more information.\n\n```toml\n[dependencies]\nlerp = { version = \"0.4\", features = [\"derive\"] }\n```\n\n```rust\nuse lerp::Lerp;\n\n#[derive(Lerp, PartialEq, Debug)]\nstruct Data {\n    a: f64,\n    b: f64\n}\n\nassert_eq!(\n    Data { a: 0.0, b: 1.0 }.lerp(Data { a: 1.0, b: 0.0 }, 0.5),\n    Data { a: 0.5, b: 0.5 }\n);\n```\n\nMore derive examples can be seen in the [tests]\n\n## Usage\n\n```toml\n[dependencies]\nlerp = \"0.4\"\n```\n\n## Documentation\n\nAuto-built from Travis: \u003chttps://coriolinus.github.io/lerp-rs/\u003e\n\n[the github issue]: https://github.com/coriolinus/lerp-rs/issues/6\n[tests]: https://github.com/coriolinus/lerp-rs/tree/master/tests/derive.rs\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoriolinus%2Flerp-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoriolinus%2Flerp-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoriolinus%2Flerp-rs/lists"}