Changeset View
Changeset View
Standalone View
Standalone View
source/blender/io/gpencil/nanosvg/nanosvg.h
| Context not available. | |||||
| return s; | return s; | ||||
| } | } | ||||
| static const char *nsvg__getNextPathItem(const char *s, char *it) | static const char *nsvg__getNextPathItem(const char *s, char *it, char cmd, int nargs) | ||||
| { | { | ||||
| it[0] = '\0'; | it[0] = '\0'; | ||||
| // Skip white spaces and commas | // Skip white spaces and commas | ||||
| Context not available. | |||||
| s++; | s++; | ||||
| if (!*s) | if (!*s) | ||||
| return s; | return s; | ||||
| /* Blender: Special case for arc command's 4th and 5th arguments. */ | |||||
| if (ELEM(cmd, 'a', 'A') && ELEM(nargs, 3, 4)) { | |||||
| it[0] = s[0]; | |||||
| it[1] = '\0'; | |||||
| s++; | |||||
| return s; | |||||
| } | |||||
| if (*s == '-' || *s == '+' || *s == '.' || nsvg__isdigit(*s)) { | if (*s == '-' || *s == '+' || *s == '.' || nsvg__isdigit(*s)) { | ||||
| s = nsvg__parseNumber(s, it, 64); | s = nsvg__parseNumber(s, it, 64); | ||||
| } | } | ||||
filedescriptor: Why does this need to be a `while` loop? I think `if` was correct here. | |||||
Done Inline ActionsTo remove -. if present. erik85: To remove `-.` if present. | |||||
| Context not available. | |||||
| static int nsvg__isCoordinate(const char *s) | static int nsvg__isCoordinate(const char *s) | ||||
| { | { | ||||
| // optional sign | /* optional sign (Blender: or dot) */ | ||||
| if (*s == '-' || *s == '+') | while (*s == '-' || *s == '+' || *s == '.') | ||||
| s++; | s++; | ||||
| // must have at least one digit | // must have at least one digit | ||||
| return nsvg__isdigit(*s); | return nsvg__isdigit(*s); | ||||
Done Inline ActionsIRC, you can use the preferred format: if (*s && (ELEM(cmd, 'a', 'A')) && (ELEM(nargs, 3, 4))) { antoniov: IRC, you can use the preferred format:
`if (*s && (ELEM(cmd, 'a', 'A')) && (ELEM(nargs, 3… | |||||
| Context not available. | |||||
| nargs = 0; | nargs = 0; | ||||
| while (*s) { | while (*s) { | ||||
| s = nsvg__getNextPathItem(s, item); | s = nsvg__getNextPathItem(s, item, cmd, nargs); | ||||
| if (!*item) | if (!*item) | ||||
| break; | break; | ||||
| if (cmd != '\0' && nsvg__isCoordinate(item)) { | if (cmd != '\0' && nsvg__isCoordinate(item)) { | ||||
| Context not available. | |||||
| s = attr[i + 1]; | s = attr[i + 1]; | ||||
| nargs = 0; | nargs = 0; | ||||
| while (*s) { | while (*s) { | ||||
| s = nsvg__getNextPathItem(s, item); | s = nsvg__getNextPathItem(s, item, '\0', nargs); | ||||
| args[nargs++] = (float)nsvg__atof(item); | args[nargs++] = (float)nsvg__atof(item); | ||||
| if (nargs >= 2) { | if (nargs >= 2) { | ||||
| if (npts == 0) | if (npts == 0) | ||||
| Context not available. | |||||
Why does this need to be a while loop? I think if was correct here.