Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/memononen/nanosvg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlessandro Roncone <alecive87@gmail.com>2016-02-18 04:12:59 +0300
committerAlessandro Roncone <alecive87@gmail.com>2016-02-18 04:12:59 +0300
commit3d8f8485f2c40bdde0558c91451a086091a5da81 (patch)
tree7c2dff5e45f466bf8edaae182a39ce52fbb5a4c0 /src
parenta523e0215f3f99d44b2dcfdf241e0e27a75e35f0 (diff)
Added nsvgDuplicatePath . Also, fixed some minor typos into the tutorial. Ref #62
Diffstat (limited to 'src')
-rw-r--r--src/nanosvg.h41
-rw-r--r--src/nanosvgrast.h3
2 files changed, 39 insertions, 5 deletions
diff --git a/src/nanosvg.h b/src/nanosvg.h
index 91dbdec..3632bf6 100644
--- a/src/nanosvg.h
+++ b/src/nanosvg.h
@@ -45,15 +45,15 @@ extern "C" {
// NanoSVG can return the paths in few different units. For example if you want to render an image, you may choose
// to get the paths in pixels, or if you are feeding the data into a CNC-cutter, you may want to use millimeters.
//
-// The units passed to NanoVG should be one of: 'px', 'pt', 'pc' 'mm', 'cm', or 'in'.
+// The units passed to NanoSVG should be one of: 'px', 'pt', 'pc' 'mm', 'cm', or 'in'.
// DPI (dots-per-inch) controls how the unit conversion is done.
//
// If you don't know or care about the units stuff, "px" and 96 should get you going.
/* Example Usage:
- // Load
- SNVGImage* image;
+ // Load SVG
+ NSVGimage* image;
image = nsvgParseFromFile("test.svg", "px", 96);
printf("size: %f x %f\n", image->width, image->height);
// Use...
@@ -166,7 +166,10 @@ NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi)
// Important note: changes the string.
NSVGimage* nsvgParse(char* input, const char* units, float dpi);
-// Deletes list of paths.
+// Duplicates a path.
+NSVGpath* nsvgDuplicatePath(NSVGpath* p);
+
+// Deletes an image.
void nsvgDelete(NSVGimage* image);
#ifdef __cplusplus
@@ -2830,6 +2833,36 @@ error:
return NULL;
}
+NSVGpath* nsvgDuplicatePath(NSVGpath* p)
+{
+ NSVGpath* res = NULL;
+
+ if (p == NULL)
+ return NULL;
+
+ res = (NSVGpath*)malloc(sizeof(NSVGpath));
+ if (res == NULL) goto error;
+ memset(res, 0, sizeof(NSVGpath));
+
+ res->pts = (float*)malloc(p->npts*2*sizeof(float));
+ if (res->pts == NULL) goto error;
+ memcpy(res->pts, p->pts, p->npts * sizeof(float) * 2);
+ res->npts = p->npts;
+
+ memcpy(res->bounds, p->bounds, sizeof(p->bounds));
+
+ res->closed = p->closed;
+
+ return res;
+
+error:
+ if (res != NULL) {
+ free(res->pts);
+ free(res);
+ }
+ return NULL;
+}
+
void nsvgDelete(NSVGimage* image)
{
NSVGshape *snext, *shape;
diff --git a/src/nanosvgrast.h b/src/nanosvgrast.h
index c71d7b4..af5da00 100644
--- a/src/nanosvgrast.h
+++ b/src/nanosvgrast.h
@@ -33,7 +33,8 @@ typedef struct NSVGrasterizer NSVGrasterizer;
/* Example Usage:
// Load SVG
- struct SNVGImage* image = nsvgParseFromFile("test.svg.");
+ NSVGimage* image;
+ image = nsvgParseFromFile("test.svg", "px", 96);
// Create rasterizer (can be used to render multiple images).
struct NSVGrasterizer* rast = nsvgCreateRasterizer();