-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Library extension #62
Comments
Hi! These sounds like interesting additions. Yes, I'd be interested to add them. |
Ok, great! First things first: is this
With "ok with you" I mean if it's ok to have a function declaration like the one above or something different (for example, |
Copy should be The above function is not in line how the rest of the lib is written (i.e. should not use those underscores), and public API should be more paranoid. Something like this: NSVGpath* nsvgDuplicatePath(NSVGpath* p)
{
NSVGpath* res = NULL;
if (p == NULL)
return NULL;
res = malloc(sizeof(NSVGpath));
if (res == NULL) goto error;
memset(res, 0, sizeof(NSVGpath));
res->pts = malloc(p->npts * sizeof(float) * 2);
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->puts);
free(res);
}
return NULL;
}
void nsvgAddPathToShape(NSVGpath* s, NSVGpath* p)
{
if (s != NULL && p != NULL) {
p->next = s->paths;
s->paths = p;
}
} I think it should not add the path to the linked list automatically. |
Ok great! I will then proceed with Some questions to go on:
|
The I don't think you need Everything in the union will occupy the same memory location. So you can only use one of the values. This is done based on the type. If the type is The one sized array in gradient is old C trick for variable sized array, take a look at how it is allocated: |
Hey @memononen ,
I really like this library, so thank you for your efforts in it! I am trying to extend it a bit in order to suit my needs. I would like to give you back my contributions disguised as pull requests and whatnot. Specifically, I am in the process of doing:
nsvgCopyGradient
nsvgCopyPaint
nsvgCopyPath
nsvgCopyShape
nsvgAppendShape
(it concatenates two shapes in order to have a single picture)nsvgTransformPath
nsvgTransformShape
...
Would you be interested in including them in the library? I think that they can be useful also for other users (but if you are not interested I will keep them on my private copy).
The text was updated successfully, but these errors were encountered: