.md →
BezierCurve API#
Bases: AnyWidget
Interactive arbitrary-degree Bezier curve editor.
Double-click to add control points, drag points to reshape the curve, and
use the play controls to advance t from 0 to 1. Coordinates synced to
Python use the configurable data bounds rather than SVG pixels.
Examples:
Create a BezierCurve widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
Iterable[dict[str, Any]] | None
|
Initial control points as |
None
|
closed
|
bool
|
Whether to append the first point virtually for rendering. |
False
|
playing
|
bool
|
Whether playback starts immediately. |
False
|
loop
|
bool
|
Whether playback wraps from |
False
|
t
|
float
|
Initial curve parameter in |
0.0
|
x_bounds
|
tuple[float, float]
|
Data-coordinate x bounds. |
(0.0, 1.0)
|
y_bounds
|
tuple[float, float]
|
Data-coordinate y bounds. |
(0.0, 1.0)
|
width
|
int
|
SVG width in pixels. |
600
|
height
|
int
|
SVG height in pixels. |
360
|
interval_ms
|
int
|
Milliseconds between browser playback ticks. |
30
|
duration_ms
|
int
|
Milliseconds for one full |
12000
|
sync_throttle_ms
|
int
|
Minimum milliseconds between playback syncs. |
250
|
**kwargs
|
Any
|
Forwarded to |
{}
|
Source code in wigglystuff/bezier_curve.py
current_point #
sample #
Sample n points along the current Bezier curve.
Source code in wigglystuff/bezier_curve.py
Synced traitlets#
| Traitlet | Type | Notes |
|---|---|---|
points |
list[dict] |
Control points as {"x": float, "y": float} in data coordinates. |
x |
float |
Current Bezier point x-coordinate at t. |
y |
float |
Current Bezier point y-coordinate at t. |
t |
float |
Curve parameter, clamped to [0, 1]. |
closed |
bool |
Whether to virtually append the first point so the curve returns to the start. |
playing |
bool |
Whether playback is currently advancing t. |
loop |
bool |
Whether playback wraps from t=1 to t=0. |
interval_ms |
int |
Milliseconds between browser playback ticks. |
duration_ms |
int |
Milliseconds for one full t=0 to t=1 traversal. |
sync_throttle_ms |
int |
Minimum milliseconds between playback updates synced to Python. |
x_bounds |
tuple[float, float] |
Data-coordinate x bounds. |
y_bounds |
tuple[float, float] |
Data-coordinate y bounds. |
width |
int |
SVG width in pixels. |
height |
int |
SVG height in pixels. |
Helper methods#
| Method | Returns | Description |
|---|---|---|
current_point() |
tuple[float, float] |
Current Bezier point at t. |
sample(n=100) |
list[dict] |
n sampled points along the curve. |