diff --git a/src/nanovg.c b/src/nanovg.c index 35ed3ef..71c49e0 100644 --- a/src/nanovg.c +++ b/src/nanovg.c @@ -1773,6 +1773,17 @@ void nvgBezierTo(struct NVGcontext* ctx, float c1x, float c1y, float c2x, float nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals)); } +void nvgQuadTo(struct NVGcontext* ctx, float cx, float cy, float x, float y) +{ + float x0 = ctx->commandx; + float y0 = ctx->commandy; + float vals[] = { NVG_BEZIERTO, + x0 + 2.0f/3.0f*(cx - x0), y0 + 2.0f/3.0f*(cy - y0), + x + 2.0f/3.0f*(cx - x), y + 2.0f/3.0f*(cy - y), + x, y }; + nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals)); +} + void nvgArcTo(struct NVGcontext* ctx, float x1, float y1, float x2, float y2, float radius) { float x0 = ctx->commandx; diff --git a/src/nanovg.h b/src/nanovg.h index b07d1fc..e3784a0 100644 --- a/src/nanovg.h +++ b/src/nanovg.h @@ -391,9 +391,12 @@ void nvgMoveTo(struct NVGcontext* ctx, float x, float y); // Adds line segment from the last point in the path to the specified point. void nvgLineTo(struct NVGcontext* ctx, float x, float y); -// Adds bezier segment from last point in the path via two control points to the specified point. +// Adds cubic bezier segment from last point in the path via two control points to the specified point. void nvgBezierTo(struct NVGcontext* ctx, float c1x, float c1y, float c2x, float c2y, float x, float y); +// Adds quadratic bezier segment from last point in the path via a control point to the specified point. +void nvgQuadTo(struct NVGcontext* ctx, float cx, float cy, float x, float y); + // Adds an arc segment at the corner defined by the last path point, and two specified points. void nvgArcTo(struct NVGcontext* ctx, float x1, float y1, float x2, float y2, float radius);