fix shapes order
This commit is contained in:
parent
ca69314cb3
commit
64c8b0c00c
@ -435,6 +435,7 @@ typedef struct NSVGparser
|
|||||||
NSVGpath* plist;
|
NSVGpath* plist;
|
||||||
NSVGimage* image;
|
NSVGimage* image;
|
||||||
NSVGgradientData* gradients;
|
NSVGgradientData* gradients;
|
||||||
|
NSVGshape *shapesTail;
|
||||||
float viewMinx, viewMiny, viewWidth, viewHeight;
|
float viewMinx, viewMiny, viewWidth, viewHeight;
|
||||||
int alignX, alignY, alignType;
|
int alignX, alignY, alignType;
|
||||||
float dpi;
|
float dpi;
|
||||||
@ -996,9 +997,13 @@ static void nsvg__addShape(NSVGparser* p)
|
|||||||
// Set flags
|
// Set flags
|
||||||
shape->flags = (attr->visible ? NSVG_FLAGS_VISIBLE : 0x00);
|
shape->flags = (attr->visible ? NSVG_FLAGS_VISIBLE : 0x00);
|
||||||
|
|
||||||
// Add to head due to performance, reverse list later
|
// Add to tail
|
||||||
shape->next = p->image->shapes;
|
if (NULL == p->image->shapes) {
|
||||||
p->image->shapes = shape;
|
p->image->shapes = shape;
|
||||||
|
} else {
|
||||||
|
p->shapesTail->next = shape;
|
||||||
|
}
|
||||||
|
p->shapesTail = shape;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -2797,16 +2802,6 @@ NSVGimage* nsvgParse(char* input, const char* units, float dpi)
|
|||||||
|
|
||||||
nsvg__parseXML(input, nsvg__startElement, nsvg__endElement, nsvg__content, p);
|
nsvg__parseXML(input, nsvg__startElement, nsvg__endElement, nsvg__content, p);
|
||||||
|
|
||||||
//reverse the list of shapes to match svg order
|
|
||||||
cur = p->image->shapes;
|
|
||||||
while (cur && cur->next != NULL) {
|
|
||||||
tmp = cur->next;
|
|
||||||
cur->next = cur->next->next;
|
|
||||||
tmp->next = p->image->shapes;
|
|
||||||
p->image->shapes = tmp;
|
|
||||||
cur = cur->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scale to viewBox
|
// Scale to viewBox
|
||||||
nsvg__scaleToViewbox(p, units);
|
nsvg__scaleToViewbox(p, units);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user