A lightweight C project using Raylib to render and interact with quadratic spline curves on a 2D grid.
It demonstrates Bézier curve rendering, grid-based rasterization, and the non-zero winding rule for filling polygons.
- Add, move, and interactively edit spline control points with the mouse.
- Rasterizes spline curves into a grid using the non-zero winding rule.
- Simple and efficient dynamic array-based spline storage.
- Real-time rendering using Raylib.
- C compiler (GCC/Clang)
- Raylib installed and linked
# Start the project (optional)
./start.sh
# Compile and run
./build/main- Left click: Add a new control point or drag an existing one.
- Mouse drag: Move existing control points.
- F2 key: Reset spline and clear the grid.
- Close window: Exit the application.
The spline is defined by a set of control points. Each quadratic Bézier segment is evaluated using:
where (
Used for filling the spline-defined area in the grid:
- Traverse the curve edges.
- Increment winding number for upward edge crossings.
- Decrement for downward edge crossings.
- Any cell with non-zero winding number is considered inside the shape.
This ensures correct filling even for complex, self-intersecting shapes.