Browse Source

Cleanup, update nanovg

tags/v0.3.2
Andrew Belt 7 years ago
parent
commit
bf94bd3c13
2 changed files with 22 additions and 6 deletions
  1. +1
    -1
      ext/nanovg
  2. +21
    -5
      src/widgets/SVGWidget.cpp

+ 1
- 1
ext/nanovg

@@ -1 +1 @@
Subproject commit bfd5d11f270ccbbf0adb4b7bbc6055cd8e8bf5a7
Subproject commit 98e551351d020087b01ae0b1d3d2d1593e3ad01f

+ 21
- 5
src/widgets/SVGWidget.cpp View File

@@ -1,8 +1,8 @@
#include "widgets.hpp"


#define DEBUG_ONLY(x) x
// #define DEBUG_ONLY(x)
// #define DEBUG_ONLY(x) x
#define DEBUG_ONLY(x)

namespace rack {

@@ -39,9 +39,6 @@ static void drawSVG(NVGcontext *vg, NSVGimage *svg) {

nvgSave(vg);

// Only evenodd fillrule is supported
if (shape->fillRule == NSVG_FILLRULE_EVENODD) {}

if (shape->opacity < 1.0)
nvgGlobalAlpha(vg, shape->opacity);

@@ -95,6 +92,25 @@ static void drawSVG(NVGcontext *vg, NSVGimage *svg) {
nvgPathWinding(vg, NVG_SOLID);
else
nvgPathWinding(vg, NVG_HOLE);

/*
// Shoelace algorithm for computing the area, and thus the winding direction
float area = 0.0;
Vec p0 = Vec(path->pts[0], path->pts[1]);
for (int i = 1; i < path->npts; i += 3) {
float *p = &path->pts[2*i];
Vec p1 = (i < path->npts) ? Vec(p[4], p[5]) : Vec(path->pts[0], path->pts[1]);
area += 0.5 * (p1.x - p0.x) * (p1.y + p0.y);
printf("%f %f, %f %f\n", p0.x, p0.y, p1.x, p1.y);
p0 = p1;
}
printf("%f\n", area);

if (area < 0.0)
nvgPathWinding(vg, NVG_CCW);
else
nvgPathWinding(vg, NVG_CW);
*/
}

// Fill shape


Loading…
Cancel
Save