| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- 1,6d0
- < //
- < // "$Id: altsvgrast.diff 12415 2017-09-03 13:20:52Z manolo $"
- < //
- <
- < /* Modified by FLTK from original sources to support non-square X,Y axes scaling */
- <
- 31d24
- <
- 51,53d43
- <
- < // For non-square X,Y scaling, use
- < nsvgAltRasterize(rast, image, 0,0,1,1, img, w, h, w*4);
- 63c53
- < // scale - image scale (assumes square aspect ratio)
- ---
- > // scale - image scale
- 72,77d61
- < // As above, but allow X and Y axes to scale independently for non-square aspects
- < void nsvgAltRasterize(NSVGrasterizer* r,
- < NSVGimage* image, float tx, float ty,
- < float sx, float sy,
- < unsigned char* dst, int w, int h, int stride);
- <
- 382c366
- < static void nsvg__flattenShape(NSVGrasterizer* r, NSVGshape* shape, float sx, float sy)
- ---
- > static void nsvg__flattenShape(NSVGrasterizer* r, NSVGshape* shape, float scale)
- 390c374
- < nsvg__addPathPoint(r, path->pts[0]*sx, path->pts[1]*sy, 0);
- ---
- > nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0);
- 393c377
- < nsvg__flattenCubicBez(r, p[0]*sx,p[1]*sy, p[2]*sx,p[3]*sy, p[4]*sx,p[5]*sy, p[6]*sx,p[7]*sy, 0, 0);
- ---
- > nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, 0);
- 396c380
- < nsvg__addPathPoint(r, path->pts[0]*sx, path->pts[1]*sy, 0);
- ---
- > nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0);
- 746c730
- < static void nsvg__flattenShapeStroke(NSVGrasterizer* r, NSVGshape* shape, float sx, float sy)
- ---
- > static void nsvg__flattenShapeStroke(NSVGrasterizer* r, NSVGshape* shape, float scale)
- 754,755c738
- < const float sw = (sx + sy) / 2; // average scaling factor
- < const float lineWidth = shape->strokeWidth * sw; // FIXME (?)
- ---
- > float lineWidth = shape->strokeWidth * scale;
- 760c743
- < nsvg__addPathPoint(r, path->pts[0]*sx, path->pts[1]*sy, NSVG_PT_CORNER);
- ---
- > nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, NSVG_PT_CORNER);
- 763c746
- < nsvg__flattenCubicBez(r, p[0]*sx,p[1]*sy, p[2]*sx,p[3]*sy, p[4]*sx,p[5]*sy, p[6]*sx,p[7]*sy, 0, NSVG_PT_CORNER);
- ---
- > nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, NSVG_PT_CORNER);
- 809c792
- < dashLen = (shape->strokeDashArray[idash] - dashOffset) * sw;
- ---
- > dashLen = (shape->strokeDashArray[idash] - dashOffset) * scale;
- 831c814
- < dashLen = shape->strokeDashArray[idash] * sw;
- ---
- > dashLen = shape->strokeDashArray[idash] * scale;
- 1000c983
- < float tx, float ty, float sx, float sy, NSVGcachedPaint* cache)
- ---
- > float tx, float ty, float scale, NSVGcachedPaint* cache)
- 1041,1043c1024,1026
- < fx = ((float)x - tx) / sx;
- < fy = ((float)y - ty) / sy;
- < dx = 1.0f / sx;
- ---
- > fx = ((float)x - tx) / scale;
- > fy = ((float)y - ty) / scale;
- > dx = 1.0f / scale;
- 1086,1088c1069,1071
- < fx = ((float)x - tx) / sx;
- < fy = ((float)y - ty) / sy;
- < dx = 1.0f / sx;
- ---
- > fx = ((float)x - tx) / scale;
- > fy = ((float)y - ty) / scale;
- > dx = 1.0f / scale;
- 1127c1110
- < static void nsvg__rasterizeSortedEdges(NSVGrasterizer *r, float tx, float ty, float sx, float sy, NSVGcachedPaint* cache, char fillRule)
- ---
- > static void nsvg__rasterizeSortedEdges(NSVGrasterizer *r, float tx, float ty, float scale, NSVGcachedPaint* cache, char fillRule)
- 1209c1192
- < nsvg__scanlineSolid(&r->bitmap[y * r->stride] + xmin*4, xmax-xmin+1, &r->scanline[xmin], xmin, y, tx,ty, sx, sy, cache);
- ---
- > nsvg__scanlineSolid(&r->bitmap[y * r->stride] + xmin*4, xmax-xmin+1, &r->scanline[xmin], xmin, y, tx,ty, scale, cache);
- 1377,1379c1360,1361
- < void nsvgAltRasterize(NSVGrasterizer* r,
- < NSVGimage* image, float tx, float ty,
- < float sx, float sy,
- ---
- > void nsvgRasterize(NSVGrasterizer* r,
- > NSVGimage* image, float tx, float ty, float scale,
- 1410c1392
- < nsvg__flattenShape(r, shape, sx, sy);
- ---
- > nsvg__flattenShape(r, shape, scale);
- 1427c1409
- < nsvg__rasterizeSortedEdges(r, tx,ty, sx, sy, &cache, shape->fillRule);
- ---
- > nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, shape->fillRule);
- 1429c1411
- < if (shape->stroke.type != NSVG_PAINT_NONE && (shape->strokeWidth * sx) > 0.01f) {
- ---
- > if (shape->stroke.type != NSVG_PAINT_NONE && (shape->strokeWidth * scale) > 0.01f) {
- 1434c1416
- < nsvg__flattenShapeStroke(r, shape, sx, sy);
- ---
- > nsvg__flattenShapeStroke(r, shape, scale);
- 1453c1435
- < nsvg__rasterizeSortedEdges(r, tx,ty,sx, sy, &cache, NSVG_FILLRULE_NONZERO);
- ---
- > nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, NSVG_FILLRULE_NONZERO);
- 1465,1477c1447
- < void nsvgRasterize(NSVGrasterizer* r,
- < NSVGimage* image, float tx, float ty, float scale,
- < unsigned char* dst, int w, int h, int stride)
- < {
- < nsvgAltRasterize(r,image, tx, ty, scale, scale, dst, w, h, stride);
- < }
- <
- < #endif // NANOSVGRAST_IMPLEMENTATION
- <
- <
- < //
- < // End of "$Id: altsvgrast.diff 12415 2017-09-03 13:20:52Z manolo $".
- < //
- ---
- > #endif
|