Merge pull request #83 from daniel-starke/master
Fix for typos, GCC warnings and shape ordering
This commit is contained in:
commit
b20e2eb968
@ -73,30 +73,30 @@ enum NSVGpaintType {
|
|||||||
NSVG_PAINT_NONE = 0,
|
NSVG_PAINT_NONE = 0,
|
||||||
NSVG_PAINT_COLOR = 1,
|
NSVG_PAINT_COLOR = 1,
|
||||||
NSVG_PAINT_LINEAR_GRADIENT = 2,
|
NSVG_PAINT_LINEAR_GRADIENT = 2,
|
||||||
NSVG_PAINT_RADIAL_GRADIENT = 3,
|
NSVG_PAINT_RADIAL_GRADIENT = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
enum NSVGspreadType {
|
enum NSVGspreadType {
|
||||||
NSVG_SPREAD_PAD = 0,
|
NSVG_SPREAD_PAD = 0,
|
||||||
NSVG_SPREAD_REFLECT = 1,
|
NSVG_SPREAD_REFLECT = 1,
|
||||||
NSVG_SPREAD_REPEAT = 2,
|
NSVG_SPREAD_REPEAT = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum NSVGlineJoin {
|
enum NSVGlineJoin {
|
||||||
NSVG_JOIN_MITER = 0,
|
NSVG_JOIN_MITER = 0,
|
||||||
NSVG_JOIN_ROUND = 1,
|
NSVG_JOIN_ROUND = 1,
|
||||||
NSVG_JOIN_BEVEL = 2,
|
NSVG_JOIN_BEVEL = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum NSVGlineCap {
|
enum NSVGlineCap {
|
||||||
NSVG_CAP_BUTT = 0,
|
NSVG_CAP_BUTT = 0,
|
||||||
NSVG_CAP_ROUND = 1,
|
NSVG_CAP_ROUND = 1,
|
||||||
NSVG_CAP_SQUARE = 2,
|
NSVG_CAP_SQUARE = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum NSVGfillRule {
|
enum NSVGfillRule {
|
||||||
NSVG_FILLRULE_NONZERO = 0,
|
NSVG_FILLRULE_NONZERO = 0,
|
||||||
NSVG_FILLRULE_EVENODD = 1,
|
NSVG_FILLRULE_EVENODD = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
enum NSVGflags {
|
enum NSVGflags {
|
||||||
@ -171,7 +171,7 @@ NSVGimage* nsvgParse(char* input, const char* units, float dpi);
|
|||||||
void nsvgDelete(NSVGimage* image);
|
void nsvgDelete(NSVGimage* image);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
};
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // NANOSVG_H
|
#endif // NANOSVG_H
|
||||||
@ -183,7 +183,7 @@ void nsvgDelete(NSVGimage* image);
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#define NSVG_PI (3.14159265358979323846264338327f)
|
#define NSVG_PI (3.14159265358979323846264338327f)
|
||||||
#define NSVG_KAPPA90 (0.5522847493f) // Lenght proportional to radius of a cubic bezier handle for 90deg arcs.
|
#define NSVG_KAPPA90 (0.5522847493f) // Length proportional to radius of a cubic bezier handle for 90deg arcs.
|
||||||
|
|
||||||
#define NSVG_ALIGN_MIN 0
|
#define NSVG_ALIGN_MIN 0
|
||||||
#define NSVG_ALIGN_MID 1
|
#define NSVG_ALIGN_MID 1
|
||||||
@ -349,7 +349,7 @@ int nsvg__parseXML(char* input,
|
|||||||
|
|
||||||
enum NSVGgradientUnits {
|
enum NSVGgradientUnits {
|
||||||
NSVG_USER_SPACE = 0,
|
NSVG_USER_SPACE = 0,
|
||||||
NSVG_OBJECT_SPACE = 1,
|
NSVG_OBJECT_SPACE = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NSVG_MAX_DASHES 8
|
#define NSVG_MAX_DASHES 8
|
||||||
@ -364,7 +364,7 @@ enum NSVGunits {
|
|||||||
NSVG_UNITS_IN,
|
NSVG_UNITS_IN,
|
||||||
NSVG_UNITS_PERCENT,
|
NSVG_UNITS_PERCENT,
|
||||||
NSVG_UNITS_EM,
|
NSVG_UNITS_EM,
|
||||||
NSVG_UNITS_EX,
|
NSVG_UNITS_EX
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct NSVGcoordinate {
|
typedef struct NSVGcoordinate {
|
||||||
@ -922,7 +922,7 @@ static void nsvg__addShape(NSVGparser* p)
|
|||||||
{
|
{
|
||||||
NSVGattrib* attr = nsvg__getAttr(p);
|
NSVGattrib* attr = nsvg__getAttr(p);
|
||||||
float scale = 1.0f;
|
float scale = 1.0f;
|
||||||
NSVGshape *shape, *cur, *prev;
|
NSVGshape* shape;
|
||||||
NSVGpath* path;
|
NSVGpath* path;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -937,7 +937,7 @@ static void nsvg__addShape(NSVGparser* p)
|
|||||||
scale = nsvg__getAverageScale(attr->xform);
|
scale = nsvg__getAverageScale(attr->xform);
|
||||||
shape->strokeWidth = attr->strokeWidth * scale;
|
shape->strokeWidth = attr->strokeWidth * scale;
|
||||||
shape->strokeDashOffset = attr->strokeDashOffset * scale;
|
shape->strokeDashOffset = attr->strokeDashOffset * scale;
|
||||||
shape->strokeDashCount = attr->strokeDashCount;
|
shape->strokeDashCount = (char)attr->strokeDashCount;
|
||||||
for (i = 0; i < attr->strokeDashCount; i++)
|
for (i = 0; i < attr->strokeDashCount; i++)
|
||||||
shape->strokeDashArray[i] = attr->strokeDashArray[i] * scale;
|
shape->strokeDashArray[i] = attr->strokeDashArray[i] * scale;
|
||||||
shape->strokeLineJoin = attr->strokeLineJoin;
|
shape->strokeLineJoin = attr->strokeLineJoin;
|
||||||
@ -2005,7 +2005,7 @@ static void nsvg__pathArcTo(NSVGparser* p, float* cpx, float* cpy, float* args,
|
|||||||
|
|
||||||
rx = fabsf(args[0]); // y radius
|
rx = fabsf(args[0]); // y radius
|
||||||
ry = fabsf(args[1]); // x radius
|
ry = fabsf(args[1]); // x radius
|
||||||
rotx = args[2] / 180.0f * NSVG_PI; // x rotation engle
|
rotx = args[2] / 180.0f * NSVG_PI; // x rotation angle
|
||||||
fa = fabsf(args[3]) > 1e-6 ? 1 : 0; // Large arc
|
fa = fabsf(args[3]) > 1e-6 ? 1 : 0; // Large arc
|
||||||
fs = fabsf(args[4]) > 1e-6 ? 1 : 0; // Sweep direction
|
fs = fabsf(args[4]) > 1e-6 ? 1 : 0; // Sweep direction
|
||||||
x1 = *cpx; // start point
|
x1 = *cpx; // start point
|
||||||
@ -2092,7 +2092,7 @@ static void nsvg__pathArcTo(NSVGparser* p, float* cpx, float* cpy, float* args,
|
|||||||
kappa = -kappa;
|
kappa = -kappa;
|
||||||
|
|
||||||
for (i = 0; i <= ndivs; i++) {
|
for (i = 0; i <= ndivs; i++) {
|
||||||
a = a1 + da * (i/(float)ndivs);
|
a = a1 + da * ((float)i/(float)ndivs);
|
||||||
dx = cosf(a);
|
dx = cosf(a);
|
||||||
dy = sinf(a);
|
dy = sinf(a);
|
||||||
nsvg__xformPoint(&x, &y, dx*rx, dy*ry, t); // position
|
nsvg__xformPoint(&x, &y, dx*rx, dy*ry, t); // position
|
||||||
@ -2791,7 +2791,6 @@ NSVGimage* nsvgParse(char* input, const char* units, float dpi)
|
|||||||
{
|
{
|
||||||
NSVGparser* p;
|
NSVGparser* p;
|
||||||
NSVGimage* ret = 0;
|
NSVGimage* ret = 0;
|
||||||
NSVGshape* cur, *tmp;
|
|
||||||
|
|
||||||
p = nsvg__createParser();
|
p = nsvg__createParser();
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
@ -2800,7 +2799,7 @@ NSVGimage* nsvgParse(char* input, const char* units, float dpi)
|
|||||||
p->dpi = dpi;
|
p->dpi = dpi;
|
||||||
|
|
||||||
nsvg__parseXML(input, nsvg__startElement, nsvg__endElement, nsvg__content, p);
|
nsvg__parseXML(input, nsvg__startElement, nsvg__endElement, nsvg__content, p);
|
||||||
|
|
||||||
// Scale to viewBox
|
// Scale to viewBox
|
||||||
nsvg__scaleToViewbox(p, units);
|
nsvg__scaleToViewbox(p, units);
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ void nsvgDeleteRasterizer(NSVGrasterizer*);
|
|||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
};
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // NANOSVGRAST_H
|
#endif // NANOSVGRAST_H
|
||||||
@ -239,7 +239,7 @@ static void nsvg__addPathPoint(NSVGrasterizer* r, float x, float y, int flags)
|
|||||||
if (r->npoints > 0) {
|
if (r->npoints > 0) {
|
||||||
pt = &r->points[r->npoints-1];
|
pt = &r->points[r->npoints-1];
|
||||||
if (nsvg__ptEquals(pt->x,pt->y, x,y, r->distTol)) {
|
if (nsvg__ptEquals(pt->x,pt->y, x,y, r->distTol)) {
|
||||||
pt->flags |= flags;
|
pt->flags = (unsigned char)(pt->flags | flags);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -388,7 +388,7 @@ enum NSVGpointFlags
|
|||||||
{
|
{
|
||||||
NSVG_PT_CORNER = 0x01,
|
NSVG_PT_CORNER = 0x01,
|
||||||
NSVG_PT_BEVEL = 0x02,
|
NSVG_PT_BEVEL = 0x02,
|
||||||
NSVG_PT_LEFT = 0x04,
|
NSVG_PT_LEFT = 0x04
|
||||||
};
|
};
|
||||||
|
|
||||||
static void nsvg__initClosed(NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth)
|
static void nsvg__initClosed(NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth)
|
||||||
@ -454,7 +454,7 @@ static void nsvg__roundCap(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right,
|
|||||||
float lx = 0, ly = 0, rx = 0, ry = 0, prevx = 0, prevy = 0;
|
float lx = 0, ly = 0, rx = 0, ry = 0, prevx = 0, prevy = 0;
|
||||||
|
|
||||||
for (i = 0; i < ncap; i++) {
|
for (i = 0; i < ncap; i++) {
|
||||||
float a = i/(float)(ncap-1)*NSVG_PI;
|
float a = (float)i/(float)(ncap-1)*NSVG_PI;
|
||||||
float ax = cosf(a) * w, ay = sinf(a) * w;
|
float ax = cosf(a) * w, ay = sinf(a) * w;
|
||||||
float x = px - dlx*ax - dx*ay;
|
float x = px - dlx*ax - dx*ay;
|
||||||
float y = py - dly*ax - dy*ay;
|
float y = py - dly*ax - dy*ay;
|
||||||
@ -551,7 +551,7 @@ static void nsvg__roundJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right
|
|||||||
if (da < NSVG_PI) da += NSVG_PI*2;
|
if (da < NSVG_PI) da += NSVG_PI*2;
|
||||||
if (da > NSVG_PI) da -= NSVG_PI*2;
|
if (da > NSVG_PI) da -= NSVG_PI*2;
|
||||||
|
|
||||||
n = (int)ceilf((nsvg__absf(da) / NSVG_PI) * ncap);
|
n = (int)ceilf((nsvg__absf(da) / NSVG_PI) * (float)ncap);
|
||||||
if (n < 2) n = 2;
|
if (n < 2) n = 2;
|
||||||
if (n > ncap) n = ncap;
|
if (n > ncap) n = ncap;
|
||||||
|
|
||||||
@ -561,7 +561,7 @@ static void nsvg__roundJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right
|
|||||||
ry = right->y;
|
ry = right->y;
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
float u = i/(float)(n-1);
|
float u = (float)i/(float)(n-1);
|
||||||
float a = a0 + u*da;
|
float a = a0 + u*da;
|
||||||
float ax = cosf(a) * w, ay = sinf(a) * w;
|
float ax = cosf(a) * w, ay = sinf(a) * w;
|
||||||
float lx1 = p1->x - ax, ly1 = p1->y - ay;
|
float lx1 = p1->x - ax, ly1 = p1->y - ay;
|
||||||
@ -838,8 +838,8 @@ static void nsvg__flattenShapeStroke(NSVGrasterizer* r, NSVGshape* shape, float
|
|||||||
|
|
||||||
static int nsvg__cmpEdge(const void *p, const void *q)
|
static int nsvg__cmpEdge(const void *p, const void *q)
|
||||||
{
|
{
|
||||||
NSVGedge* a = (NSVGedge*)p;
|
const NSVGedge* a = (const NSVGedge*)p;
|
||||||
NSVGedge* b = (NSVGedge*)q;
|
const NSVGedge* b = (const NSVGedge*)q;
|
||||||
|
|
||||||
if (a->y0 < b->y0) return -1;
|
if (a->y0 < b->y0) return -1;
|
||||||
if (a->y0 > b->y0) return 1;
|
if (a->y0 > b->y0) return 1;
|
||||||
@ -892,20 +892,20 @@ static void nsvg__fillScanline(unsigned char* scanline, int len, int x0, int x1,
|
|||||||
if (i < len && j >= 0) {
|
if (i < len && j >= 0) {
|
||||||
if (i == j) {
|
if (i == j) {
|
||||||
// x0,x1 are the same pixel, so compute combined coverage
|
// x0,x1 are the same pixel, so compute combined coverage
|
||||||
scanline[i] += (unsigned char)((x1 - x0) * maxWeight >> NSVG__FIXSHIFT);
|
scanline[i] = (unsigned char)(scanline[i] + ((x1 - x0) * maxWeight >> NSVG__FIXSHIFT));
|
||||||
} else {
|
} else {
|
||||||
if (i >= 0) // add antialiasing for x0
|
if (i >= 0) // add antialiasing for x0
|
||||||
scanline[i] += (unsigned char)(((NSVG__FIX - (x0 & NSVG__FIXMASK)) * maxWeight) >> NSVG__FIXSHIFT);
|
scanline[i] = (unsigned char)(scanline[i] + (((NSVG__FIX - (x0 & NSVG__FIXMASK)) * maxWeight) >> NSVG__FIXSHIFT));
|
||||||
else
|
else
|
||||||
i = -1; // clip
|
i = -1; // clip
|
||||||
|
|
||||||
if (j < len) // add antialiasing for x1
|
if (j < len) // add antialiasing for x1
|
||||||
scanline[j] += (unsigned char)(((x1 & NSVG__FIXMASK) * maxWeight) >> NSVG__FIXSHIFT);
|
scanline[j] = (unsigned char)(scanline[j] + (((x1 & NSVG__FIXMASK) * maxWeight) >> NSVG__FIXSHIFT));
|
||||||
else
|
else
|
||||||
j = len; // clip
|
j = len; // clip
|
||||||
|
|
||||||
for (++i; i < j; ++i) // fill pixels between x0 and x1
|
for (++i; i < j; ++i) // fill pixels between x0 and x1
|
||||||
scanline[i] += (unsigned char)maxWeight;
|
scanline[i] = (unsigned char)(scanline[i] + maxWeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1021,8 +1021,8 @@ static void nsvg__scanlineSolid(unsigned char* dst, int count, unsigned char* co
|
|||||||
int i, cr, cg, cb, ca;
|
int i, cr, cg, cb, ca;
|
||||||
unsigned int c;
|
unsigned int c;
|
||||||
|
|
||||||
fx = (x - tx) / scale;
|
fx = ((float)x - tx) / scale;
|
||||||
fy = (y - ty) / scale;
|
fy = ((float)y - ty) / scale;
|
||||||
dx = 1.0f / scale;
|
dx = 1.0f / scale;
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
@ -1066,8 +1066,8 @@ static void nsvg__scanlineSolid(unsigned char* dst, int count, unsigned char* co
|
|||||||
int i, cr, cg, cb, ca;
|
int i, cr, cg, cb, ca;
|
||||||
unsigned int c;
|
unsigned int c;
|
||||||
|
|
||||||
fx = (x - tx) / scale;
|
fx = ((float)x - tx) / scale;
|
||||||
fy = (y - ty) / scale;
|
fy = ((float)y - ty) / scale;
|
||||||
dx = 1.0f / scale;
|
dx = 1.0f / scale;
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
@ -1121,7 +1121,7 @@ static void nsvg__rasterizeSortedEdges(NSVGrasterizer *r, float tx, float ty, fl
|
|||||||
xmax = 0;
|
xmax = 0;
|
||||||
for (s = 0; s < NSVG__SUBSAMPLES; ++s) {
|
for (s = 0; s < NSVG__SUBSAMPLES; ++s) {
|
||||||
// find center of pixel for this scanline
|
// find center of pixel for this scanline
|
||||||
float scany = y*NSVG__SUBSAMPLES + s + 0.5f;
|
float scany = (float)(y*NSVG__SUBSAMPLES + s) + 0.5f;
|
||||||
NSVGactiveEdge **step = &active;
|
NSVGactiveEdge **step = &active;
|
||||||
|
|
||||||
// update all active edges;
|
// update all active edges;
|
||||||
|
Loading…
Reference in New Issue
Block a user