Browse Source

Fix for issue #111

- added nvgQuadTo, draws quadratic bezier curve segment
shared-context
Mikko Mononen 11 years ago
parent
commit
a98d17cf24
2 changed files with 15 additions and 1 deletions
  1. +11
    -0
      src/nanovg.c
  2. +4
    -1
      src/nanovg.h

+ 11
- 0
src/nanovg.c View File

@@ -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;


+ 4
- 1
src/nanovg.h View File

@@ -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);



Loading…
Cancel
Save