Skip to main content

Approximate or interpolate a sequence of points into a sequence of c2-continuous, non-rational cubic Bézier curves.

Project description

Non-rational Bezier curves and splines (composite Bezier curves)

This package exists mostly to create C2-continuous, non-rational cubic Bezier splines. In other words, this will approximate or interpolate a sequence of points into a sequence of non-rational cubic Bezier curves.

Should be relatively fast, but this isn't suited for heavy math. This is for taking some points you have and making a nice-looking curve out of them. Specifically, a cubic Bezier spline, which is made from the type of curves used in SVG, fonts, and other vector-base programs. I am only interested in feature requests that directly apply to that purpose. This is not an exercise in completism.

install

pip install cubic_bezier_spline

this package will

  • Evaluate, differentiate, elevate, and split non-rational Bezier curves of any degree
  • Construct non-rational cubic Bezier splines (open and closed, approximating and interpolating)
  • Evaluate and differentiate non-rational Bezier splines of any degree

this package will not**

  • Work with rational Bezier splines, b-splines, NURBS, or any other generalization of Bezier curves
  • Decrease curve degree
  • Approximate curve intersections
  • Approximate the length of a curve
  • "Stroke" (move left or right) a curve

** much of the "will not" features can be found here: https://github.com/dhermes/bezier

Public classes / functions

# a c2-continuous cubic Bezier spline near the control points
new_open_approximating_spline([(x0, y0), (x1, y1), ...])

# a c2-continuous cubic Bezier spline near the control points
new_closed_approximating_spline([(x0, y0), (x1, y1), ...])

# a c2-continuous cubic Bezier spline through the control points
new_open_interpolating_spline([(x0, y0), (x1, y1), ...])

# a c2-continuous cubic Bezier spline through the control points
new_closed_interpolating_spline([(x0, y0), (x1, y1), ...])

Any of these will return a BezierSpline object. This object has a some of the usual methods (e.g., elevate, derivative, split) to help find path normals or do some light modeling, but you may be most interested in.

# plot the spline at a given point, where time is 0 to
# (number of input points + 1)
spline(time: float)

# an svg data string
# (the d="" attribute of an SVG path object)
spline.svg_data

Examples

Some of these use double and triple repeated points to create "knots". This isn't a special function, just a feature of Bezier math. The idea is clearer with a picture.

knot examples

Most of the math can be found in:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cubic_bezier_spline-0.3.2.tar.gz (2.1 MB view details)

Uploaded Source

Built Distribution

cubic_bezier_spline-0.3.2-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file cubic_bezier_spline-0.3.2.tar.gz.

File metadata

  • Download URL: cubic_bezier_spline-0.3.2.tar.gz
  • Upload date:
  • Size: 2.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for cubic_bezier_spline-0.3.2.tar.gz
Algorithm Hash digest
SHA256 43818987c8a9ebd20e0fd50c025d7fa01909f101524ffa33d87b1516ec2035e5
MD5 7e8e779dfb27201f83db303ba249708f
BLAKE2b-256 e8ffdee65430c4764717e231b68f9d4371a59c58e3f163969b0f8e2b25dc20d0

See more details on using hashes here.

File details

Details for the file cubic_bezier_spline-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for cubic_bezier_spline-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ad7d988f4b15158e349207fc6cfc908aa4e92f6cb4ee9b7ac45e70ef0355f36f
MD5 fc7af81d5b8a29d67a77f6bef51f392d
BLAKE2b-256 6508532cfc4b08bd6b258e0ba43911612b0e054e8edf2c9a607f72ed9f914fec

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page