diff src/shape_path.c @ 711:da794f4fe96c

save and restore initial point at m and z commands of path
author Thinker K.F. Li <thinker@branda.to>
date Fri, 13 Aug 2010 19:50:16 +0800
parents 920c9e6e4214
children abd9bbf24545
line wrap: on
line diff
--- a/src/shape_path.c	Fri Aug 13 18:23:44 2010 +0800
+++ b/src/shape_path.c	Fri Aug 13 19:50:16 2010 +0800
@@ -570,6 +570,7 @@
     char cmd;
     co_aix *pnts;
     co_aix *float_args;
+    co_aix sx = 0, sy = 0;
     co_aix x, y;
     int r;
 
@@ -684,8 +685,37 @@
 		*cmds++ = toupper(cmd);
 	    }
 	    break;
+
 	case 'm':
 	case 'M':
+	    while(*p) {
+		old = p;
+		SKIP_SPACE(p);
+		old = p;
+		SKIP_NUM(p);
+		if(p == old)
+		    break;
+		*pnts = TO_ABSX;
+		x = *pnts;
+		pnts++;
+
+		SKIP_SPACE(p);
+		old = p;
+		SKIP_NUM(p);
+		if(p == old)
+		    return ERR;
+		*pnts = TO_ABSY;
+		y = *pnts;
+		pnts++;
+
+		*cmds++ = toupper(cmd);
+
+		/* save initial point of a subpath */
+		sx = x;
+		sy = y;
+	    }
+	    break;
+		
 	case 'l':
 	case 'L':
 	case 't':
@@ -732,6 +762,9 @@
 	case 'z':
 	case 'Z':
 	    *cmds++ = toupper(cmd);
+	    /* Go back to initial point of a subpath */
+	    x = sx;
+	    y = sy;
 	    break;
 	default:
 	    return ERR;