Git Product home page Git Product logo

nicodemus26 / stroke-rs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dorianprill/stroke

0.0 2.0 0.0 481 KB

A zero-allocation library providing const-generic implementations of Bézier curves, B-Spline curves and specialized implementations of up to cubic Bézier curves in N-dimensional euclidean space. It is intended for general/embedded/wasm use supporting #![no_std] environments written in 100% safe Rust.

License: MIT License

Rust 100.00%

stroke-rs's Introduction

stroke-rs

Rust
A zero-allocation library providing const-generic implementations of Bézier curves, B-Spline curves and specialized implementations of up to cubic Bézier curves in N-dimensional euclidean space. It is intended for general/embedded/wasm use supporting #![no_std] environments written in 100% safe Rust.

The library makes heavy use of const-generics and some related unstabilized features, so the nightly compiler is required.
It comes with a const-generic N-dimensional Point type so you can use the library without any other dependencies.
Should you want to integrate with types provided by another library, you are able to do so by implementing the small Point trait that the library relies upon (given it makes no distinction between a point and its position vector).

A Cubic Bézier Curve with Bounding Box and Convex Hull rendered by plotters.rs

made with plotters.rs

Right now, the generic versions don't implement all methods that the specialized versions do (as the algorithms get a bit more complicated) but should reach parity eventually.

Goals

  • Support no-std for both 32 and 64 bit targets
  • Provide lines
  • Provide quadratic Béziers
  • Provide cubic Béziers
  • Methods: evaluate, split, arc length, bounding box, derivatives
  • Where applicable: tight box, the curve's normal, curvature/radius
  • Provide general Bézier curves (eval(), split(), derivative())
  • Provide general B-Splines (eval(), arclen())
  • Good test coverage for unit tests (still needs some more)
  • Integration tests for other generic math libraries (TBD - maybe optimath, aljabar, micromath, nalgebra) since Point types are replicated in many libraries

Non-Goals

  • Focus on use for rendering or highest performance (no GPU)

Related

If you're looking for a published crate for rendering with gpu support you should check out Lyon from which I draw some inspiration, it's really good. It features lines, quadratic and cubic Béziers, in addition to arcs, triangles, and other geometric objects but no general Bézier curves or B-Splines. It also does seem to support wasm.

Also, there's Twinklebear/bspline which is a very clean and useful library for just bsplines. However, it depends on std and its simple Interpolate trait defines no way to access the individual dimensions of the points and hence implements no derivatives in the library.

This clear online book A Primer on Bézier Curves helped me with a lot of the algorithms involved.

stroke-rs's People

Contributors

dorianprill avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.