diff --git a/src/nanosvg.h b/src/nanosvg.h index 40ebac7..c49de48 100644 --- a/src/nanosvg.h +++ b/src/nanosvg.h @@ -73,30 +73,30 @@ enum NSVGpaintType { NSVG_PAINT_NONE = 0, NSVG_PAINT_COLOR = 1, NSVG_PAINT_LINEAR_GRADIENT = 2, - NSVG_PAINT_RADIAL_GRADIENT = 3, + NSVG_PAINT_RADIAL_GRADIENT = 3 }; enum NSVGspreadType { NSVG_SPREAD_PAD = 0, NSVG_SPREAD_REFLECT = 1, - NSVG_SPREAD_REPEAT = 2, + NSVG_SPREAD_REPEAT = 2 }; enum NSVGlineJoin { NSVG_JOIN_MITER = 0, NSVG_JOIN_ROUND = 1, - NSVG_JOIN_BEVEL = 2, + NSVG_JOIN_BEVEL = 2 }; enum NSVGlineCap { NSVG_CAP_BUTT = 0, NSVG_CAP_ROUND = 1, - NSVG_CAP_SQUARE = 2, + NSVG_CAP_SQUARE = 2 }; enum NSVGfillRule { NSVG_FILLRULE_NONZERO = 0, - NSVG_FILLRULE_EVENODD = 1, + NSVG_FILLRULE_EVENODD = 1 }; enum NSVGflags { @@ -171,7 +171,7 @@ NSVGimage* nsvgParse(char* input, const char* units, float dpi); void nsvgDelete(NSVGimage* image); #ifdef __cplusplus -}; +} #endif #endif // NANOSVG_H @@ -183,7 +183,7 @@ void nsvgDelete(NSVGimage* image); #include #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_MID 1 @@ -349,7 +349,7 @@ int nsvg__parseXML(char* input, enum NSVGgradientUnits { NSVG_USER_SPACE = 0, - NSVG_OBJECT_SPACE = 1, + NSVG_OBJECT_SPACE = 1 }; #define NSVG_MAX_DASHES 8 @@ -364,7 +364,7 @@ enum NSVGunits { NSVG_UNITS_IN, NSVG_UNITS_PERCENT, NSVG_UNITS_EM, - NSVG_UNITS_EX, + NSVG_UNITS_EX }; typedef struct NSVGcoordinate { @@ -921,7 +921,7 @@ static void nsvg__addShape(NSVGparser* p) { NSVGattrib* attr = nsvg__getAttr(p); float scale = 1.0f; - NSVGshape *shape, *cur, *prev; + NSVGshape *shape; NSVGpath* path; int i; @@ -936,7 +936,7 @@ static void nsvg__addShape(NSVGparser* p) scale = nsvg__getAverageScale(attr->xform); shape->strokeWidth = attr->strokeWidth * scale; shape->strokeDashOffset = attr->strokeDashOffset * scale; - shape->strokeDashCount = attr->strokeDashCount; + shape->strokeDashCount = (char)attr->strokeDashCount; for (i = 0; i < attr->strokeDashCount; i++) shape->strokeDashArray[i] = attr->strokeDashArray[i] * scale; shape->strokeLineJoin = attr->strokeLineJoin; @@ -2001,7 +2001,7 @@ static void nsvg__pathArcTo(NSVGparser* p, float* cpx, float* cpy, float* args, rx = fabsf(args[0]); // y 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 fs = fabsf(args[4]) > 1e-6 ? 1 : 0; // Sweep direction x1 = *cpx; // start point @@ -2088,7 +2088,7 @@ static void nsvg__pathArcTo(NSVGparser* p, float* cpx, float* cpy, float* args, kappa = -kappa; for (i = 0; i <= ndivs; i++) { - a = a1 + da * (i/(float)ndivs); + a = a1 + da * ((float)i/(float)ndivs); dx = cosf(a); dy = sinf(a); nsvg__xformPoint(&x, &y, dx*rx, dy*ry, t); // position @@ -2796,8 +2796,8 @@ NSVGimage* nsvgParse(char* input, const char* units, float dpi) p->dpi = dpi; nsvg__parseXML(input, nsvg__startElement, nsvg__endElement, nsvg__content, p); - - //reverse the list of shapes to match svg order + + // Reverse the list of shapes to match SVG order cur = p->image->shapes; while (cur && cur->next != NULL) { tmp = cur->next; diff --git a/src/nanosvgrast.h b/src/nanosvgrast.h index 08db3d9..2940c1f 100644 --- a/src/nanosvgrast.h +++ b/src/nanosvgrast.h @@ -64,7 +64,7 @@ void nsvgDeleteRasterizer(NSVGrasterizer*); #ifdef __cplusplus -}; +} #endif #endif // NANOSVGRAST_H @@ -239,7 +239,7 @@ static void nsvg__addPathPoint(NSVGrasterizer* r, float x, float y, int flags) if (r->npoints > 0) { pt = &r->points[r->npoints-1]; if (nsvg__ptEquals(pt->x,pt->y, x,y, r->distTol)) { - pt->flags |= flags; + pt->flags = (unsigned char)(pt->flags | flags); return; } } @@ -388,7 +388,7 @@ enum NSVGpointFlags { NSVG_PT_CORNER = 0x01, 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) @@ -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; 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 x = px - dlx*ax - dx*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; - 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 > ncap) n = ncap; @@ -561,7 +561,7 @@ static void nsvg__roundJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right ry = right->y; 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 ax = cosf(a) * w, ay = sinf(a) * w; 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) { - NSVGedge* a = (NSVGedge*)p; - NSVGedge* b = (NSVGedge*)q; + const NSVGedge* a = (const NSVGedge*)p; + const NSVGedge* b = (const NSVGedge*)q; 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 == j) { // 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 { 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 i = -1; // clip 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 j = len; // clip 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; unsigned int c; - fx = (x - tx) / scale; - fy = (y - ty) / scale; + fx = ((float)x - tx) / scale; + fy = ((float)y - ty) / scale; dx = 1.0f / scale; 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; unsigned int c; - fx = (x - tx) / scale; - fy = (y - ty) / scale; + fx = ((float)x - tx) / scale; + fy = ((float)y - ty) / scale; dx = 1.0f / scale; for (i = 0; i < count; i++) { @@ -1121,7 +1121,7 @@ static void nsvg__rasterizeSortedEdges(NSVGrasterizer *r, float tx, float ty, fl xmax = 0; for (s = 0; s < NSVG__SUBSAMPLES; ++s) { // 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; // update all active edges;