Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spline Rendering

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.

Features

  • 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.

Getting Started

Prerequisites

  • C compiler (GCC/Clang)
  • Raylib installed and linked

Build and Run

# Start the project (optional)
./start.sh

# Compile and run
./build/main

Controls

  • 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.

Quadratic Bézier Curve

The spline is defined by a set of control points. Each quadratic Bézier segment is evaluated using:

$$ B(t) = (1-t)^2 P_0 + 2(1-t)t P_1 + t^2 P_2, \quad t \in [0,1] $$

where ($P_0$, $P_1$, $P_2$) are consecutive control points.

Non-zero Winding Rule

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.

References

About

Exploring Quadratic Bézier Curves Visually

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages