mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 21:53:41 +00:00
SvgPath: When path end(Z,z), Current point are returned to starting point(M,m)
When path ends with 'z' or 'Z' command, if 'm' comes as next command, the current point is incorrectly referenced. Since 'Z', 'z' means to close the path, so, Save point and reuse it when 'M' or 'm' is called.
This commit is contained in:
parent
87a0666034
commit
cf4edcf593
1 changed files with 5 additions and 2 deletions
|
@ -280,7 +280,7 @@ static int _numberCount(char cmd)
|
|||
}
|
||||
|
||||
|
||||
static void _processCommand(vector<PathCommand>* cmds, vector<Point>* pts, char cmd, float* arr, int count, Point* cur, Point* curCtl, bool *isQuadratic)
|
||||
static void _processCommand(vector<PathCommand>* cmds, vector<Point>* pts, char cmd, float* arr, int count, Point* cur, Point* curCtl, Point* startPoint, bool *isQuadratic)
|
||||
{
|
||||
int i;
|
||||
switch (cmd) {
|
||||
|
@ -321,6 +321,7 @@ static void _processCommand(vector<PathCommand>* cmds, vector<Point>* pts, char
|
|||
cmds->push_back(PathCommand::MoveTo);
|
||||
pts->push_back(p);
|
||||
*cur = {arr[0] ,arr[1]};
|
||||
*startPoint = {arr[0] ,arr[1]};
|
||||
break;
|
||||
}
|
||||
case 'l':
|
||||
|
@ -432,6 +433,7 @@ static void _processCommand(vector<PathCommand>* cmds, vector<Point>* pts, char
|
|||
case 'z':
|
||||
case 'Z': {
|
||||
cmds->push_back(PathCommand::Close);
|
||||
*cur = *startPoint;
|
||||
break;
|
||||
}
|
||||
case 'a':
|
||||
|
@ -503,6 +505,7 @@ tuple<vector<PathCommand>, vector<Point>> svgPathToTvgPath(const char* svgPath)
|
|||
int numberCount = 0;
|
||||
Point cur = { 0, 0 };
|
||||
Point curCtl = { 0, 0 };
|
||||
Point startPoint = { 0, 0 };
|
||||
char cmd = 0;
|
||||
bool isQuadratic = false;
|
||||
char* path = (char*)svgPath;
|
||||
|
@ -515,7 +518,7 @@ tuple<vector<PathCommand>, vector<Point>> svgPathToTvgPath(const char* svgPath)
|
|||
while ((path[0] != '\0')) {
|
||||
path = _nextCommand(path, &cmd, numberArray, &numberCount);
|
||||
if (!path) break;
|
||||
_processCommand(&cmds, &pts, cmd, numberArray, numberCount, &cur, &curCtl, &isQuadratic);
|
||||
_processCommand(&cmds, &pts, cmd, numberArray, numberCount, &cur, &curCtl, &startPoint, &isQuadratic);
|
||||
}
|
||||
|
||||
setlocale(LC_NUMERIC, curLocale);
|
||||
|
|
Loading…
Add table
Reference in a new issue