Fossil SCM
Update to the latest pikchr.c that fixes issues with the "close" attribute.
Commit
c9bc2b4a8d3d849277b4f635a9a0957a7411b11c1ee4811e216242ea2b3ea6c3
Parent
b6b5a7dc6246b2c…
1 file changed
+18
-12
+18
-12
| --- src/pikchr.c | ||
| +++ src/pikchr.c | ||
| @@ -3612,11 +3612,10 @@ | ||
| 3612 | 3612 | /* Methods for the "arrow" class */ |
| 3613 | 3613 | static void arrowInit(Pik *p, PObj *pObj){ |
| 3614 | 3614 | pObj->w = pik_value(p, "linewid",7,0); |
| 3615 | 3615 | pObj->h = pik_value(p, "lineht",6,0); |
| 3616 | 3616 | pObj->rad = pik_value(p, "linerad",7,0); |
| 3617 | - pObj->fill = -1.0; | |
| 3618 | 3617 | pObj->rarrow = 1; |
| 3619 | 3618 | } |
| 3620 | 3619 | |
| 3621 | 3620 | /* Methods for the "box" class */ |
| 3622 | 3621 | static void boxInit(Pik *p, PObj *pObj){ |
| @@ -4033,11 +4032,10 @@ | ||
| 4033 | 4032 | /* Methods for the "line" class */ |
| 4034 | 4033 | static void lineInit(Pik *p, PObj *pObj){ |
| 4035 | 4034 | pObj->w = pik_value(p, "linewid",7,0); |
| 4036 | 4035 | pObj->h = pik_value(p, "lineht",6,0); |
| 4037 | 4036 | pObj->rad = pik_value(p, "linerad",7,0); |
| 4038 | - pObj->fill = -1.0; | |
| 4039 | 4037 | } |
| 4040 | 4038 | static PPoint lineOffset(Pik *p, PObj *pObj, int cp){ |
| 4041 | 4039 | #if 0 |
| 4042 | 4040 | /* In legacy PIC, the .center of an unclosed line is half way between |
| 4043 | 4041 | ** its .start and .end. */ |
| @@ -4117,11 +4115,10 @@ | ||
| 4117 | 4115 | /* Methods for the "spline" class */ |
| 4118 | 4116 | static void splineInit(Pik *p, PObj *pObj){ |
| 4119 | 4117 | pObj->w = pik_value(p, "linewid",7,0); |
| 4120 | 4118 | pObj->h = pik_value(p, "lineht",6,0); |
| 4121 | 4119 | pObj->rad = 1000; |
| 4122 | - pObj->fill = -1.0; /* Disable fill by default */ | |
| 4123 | 4120 | } |
| 4124 | 4121 | /* Return a point along the path from "f" to "t" that is r units |
| 4125 | 4122 | ** prior to reaching "t", except if the path is less than 2*r total, |
| 4126 | 4123 | ** return the midpoint. |
| 4127 | 4124 | */ |
| @@ -4146,27 +4143,35 @@ | ||
| 4146 | 4143 | static void radiusPath(Pik *p, PObj *pObj, PNum r){ |
| 4147 | 4144 | int i; |
| 4148 | 4145 | int n = pObj->nPath; |
| 4149 | 4146 | const PPoint *a = pObj->aPath; |
| 4150 | 4147 | PPoint m; |
| 4148 | + PPoint an = a[n-1]; | |
| 4151 | 4149 | int isMid = 0; |
| 4150 | + int iLast = pObj->bClose ? n : n-1; | |
| 4152 | 4151 | |
| 4153 | 4152 | pik_append_xy(p,"<path d=\"M", a[0].x, a[0].y); |
| 4154 | 4153 | m = radiusMidpoint(a[0], a[1], r, &isMid); |
| 4155 | 4154 | pik_append_xy(p," L ",m.x,m.y); |
| 4156 | - for(i=1; i<n-1; i++){ | |
| 4157 | - m = radiusMidpoint(a[i+1],a[i],r, &isMid); | |
| 4155 | + for(i=1; i<iLast; i++){ | |
| 4156 | + an = i<n-1 ? a[i+1] : a[0]; | |
| 4157 | + m = radiusMidpoint(an,a[i],r, &isMid); | |
| 4158 | 4158 | pik_append_xy(p," Q ",a[i].x,a[i].y); |
| 4159 | 4159 | pik_append_xy(p," ",m.x,m.y); |
| 4160 | 4160 | if( !isMid ){ |
| 4161 | - m = radiusMidpoint(a[i],a[i+1],r, &isMid); | |
| 4161 | + m = radiusMidpoint(a[i],an,r, &isMid); | |
| 4162 | 4162 | pik_append_xy(p," L ",m.x,m.y); |
| 4163 | 4163 | } |
| 4164 | 4164 | } |
| 4165 | - pik_append_xy(p," L ",a[i].x,a[i].y); | |
| 4165 | + pik_append_xy(p," L ",an.x,an.y); | |
| 4166 | + if( pObj->bClose ){ | |
| 4167 | + pik_append(p,"Z",1); | |
| 4168 | + }else{ | |
| 4169 | + pObj->fill = -1.0; | |
| 4170 | + } | |
| 4166 | 4171 | pik_append(p,"\" ",-1); |
| 4167 | - pik_append_style(p,pObj,0); | |
| 4172 | + pik_append_style(p,pObj,pObj->bClose); | |
| 4168 | 4173 | pik_append(p,"\" />\n", -1); |
| 4169 | 4174 | } |
| 4170 | 4175 | static void splineRender(Pik *p, PObj *pObj){ |
| 4171 | 4176 | if( pObj->sw>0.0 ){ |
| 4172 | 4177 | int n = pObj->nPath; |
| @@ -4804,12 +4809,12 @@ | ||
| 4804 | 4809 | jw = 0.0; |
| 4805 | 4810 | } |
| 4806 | 4811 | for(i=0; i<n; i++){ |
| 4807 | 4812 | PToken *t = &aTxt[i]; |
| 4808 | 4813 | PNum xtraFontScale = pik_font_scale(t); |
| 4809 | - orig_y = pObj->ptAt.y; | |
| 4810 | 4814 | PNum nx = 0; |
| 4815 | + orig_y = pObj->ptAt.y; | |
| 4811 | 4816 | y = 0; |
| 4812 | 4817 | if( t->eCode & TP_ABOVE2 ) y += 0.5*hc + ha1 + 0.5*ha2; |
| 4813 | 4818 | if( t->eCode & TP_ABOVE ) y += 0.5*hc + 0.5*ha1; |
| 4814 | 4819 | if( t->eCode & TP_BELOW ) y -= 0.5*hc + 0.5*hb1; |
| 4815 | 4820 | if( t->eCode & TP_BELOW2 ) y -= 0.5*hc + hb1 + 0.5*hb2; |
| @@ -5285,12 +5290,13 @@ | ||
| 5285 | 5290 | pNew->type->xInit(p, pNew); |
| 5286 | 5291 | pik_add_txt(p, pStr, pStr->eCode); |
| 5287 | 5292 | return pNew; |
| 5288 | 5293 | } |
| 5289 | 5294 | if( pId ){ |
| 5295 | + const PClass *pClass; | |
| 5290 | 5296 | pNew->errTok = *pId; |
| 5291 | - const PClass *pClass = pik_find_class(pId); | |
| 5297 | + pClass = pik_find_class(pId); | |
| 5292 | 5298 | if( pClass ){ |
| 5293 | 5299 | pNew->type = pClass; |
| 5294 | 5300 | pNew->sw = pik_value(p, "thickness",9,0); |
| 5295 | 5301 | pNew->fill = pik_value(p, "fill",4,0); |
| 5296 | 5302 | pNew->color = pik_value(p, "color",5,0); |
| @@ -6721,18 +6727,18 @@ | ||
| 6721 | 6727 | bMoreToDo = 0; |
| 6722 | 6728 | iThisLayer = iNextLayer; |
| 6723 | 6729 | iNextLayer = 0x7fffffff; |
| 6724 | 6730 | for(i=0; i<pList->n; i++){ |
| 6725 | 6731 | PObj *pObj = pList->a[i]; |
| 6732 | + void (*xRender)(Pik*,PObj*); | |
| 6726 | 6733 | if( pObj->iLayer>iThisLayer ){ |
| 6727 | 6734 | if( pObj->iLayer<iNextLayer ) iNextLayer = pObj->iLayer; |
| 6728 | 6735 | bMoreToDo = 1; |
| 6729 | 6736 | continue; /* Defer until another round */ |
| 6730 | 6737 | }else if( pObj->iLayer<iThisLayer ){ |
| 6731 | 6738 | continue; |
| 6732 | 6739 | } |
| 6733 | - void (*xRender)(Pik*,PObj*); | |
| 6734 | 6740 | if( mDebug & 1 ) pik_elem_render(p, pObj); |
| 6735 | 6741 | xRender = pObj->type->xRender; |
| 6736 | 6742 | if( xRender ){ |
| 6737 | 6743 | xRender(p, pObj); |
| 6738 | 6744 | } |
| @@ -7774,6 +7780,6 @@ | ||
| 7774 | 7780 | |
| 7775 | 7781 | |
| 7776 | 7782 | #endif /* PIKCHR_TCL */ |
| 7777 | 7783 | |
| 7778 | 7784 | |
| 7779 | -#line 7804 "pikchr.c" | |
| 7785 | +#line 7810 "pikchr.c" | |
| 7780 | 7786 |
| --- src/pikchr.c | |
| +++ src/pikchr.c | |
| @@ -3612,11 +3612,10 @@ | |
| 3612 | /* Methods for the "arrow" class */ |
| 3613 | static void arrowInit(Pik *p, PObj *pObj){ |
| 3614 | pObj->w = pik_value(p, "linewid",7,0); |
| 3615 | pObj->h = pik_value(p, "lineht",6,0); |
| 3616 | pObj->rad = pik_value(p, "linerad",7,0); |
| 3617 | pObj->fill = -1.0; |
| 3618 | pObj->rarrow = 1; |
| 3619 | } |
| 3620 | |
| 3621 | /* Methods for the "box" class */ |
| 3622 | static void boxInit(Pik *p, PObj *pObj){ |
| @@ -4033,11 +4032,10 @@ | |
| 4033 | /* Methods for the "line" class */ |
| 4034 | static void lineInit(Pik *p, PObj *pObj){ |
| 4035 | pObj->w = pik_value(p, "linewid",7,0); |
| 4036 | pObj->h = pik_value(p, "lineht",6,0); |
| 4037 | pObj->rad = pik_value(p, "linerad",7,0); |
| 4038 | pObj->fill = -1.0; |
| 4039 | } |
| 4040 | static PPoint lineOffset(Pik *p, PObj *pObj, int cp){ |
| 4041 | #if 0 |
| 4042 | /* In legacy PIC, the .center of an unclosed line is half way between |
| 4043 | ** its .start and .end. */ |
| @@ -4117,11 +4115,10 @@ | |
| 4117 | /* Methods for the "spline" class */ |
| 4118 | static void splineInit(Pik *p, PObj *pObj){ |
| 4119 | pObj->w = pik_value(p, "linewid",7,0); |
| 4120 | pObj->h = pik_value(p, "lineht",6,0); |
| 4121 | pObj->rad = 1000; |
| 4122 | pObj->fill = -1.0; /* Disable fill by default */ |
| 4123 | } |
| 4124 | /* Return a point along the path from "f" to "t" that is r units |
| 4125 | ** prior to reaching "t", except if the path is less than 2*r total, |
| 4126 | ** return the midpoint. |
| 4127 | */ |
| @@ -4146,27 +4143,35 @@ | |
| 4146 | static void radiusPath(Pik *p, PObj *pObj, PNum r){ |
| 4147 | int i; |
| 4148 | int n = pObj->nPath; |
| 4149 | const PPoint *a = pObj->aPath; |
| 4150 | PPoint m; |
| 4151 | int isMid = 0; |
| 4152 | |
| 4153 | pik_append_xy(p,"<path d=\"M", a[0].x, a[0].y); |
| 4154 | m = radiusMidpoint(a[0], a[1], r, &isMid); |
| 4155 | pik_append_xy(p," L ",m.x,m.y); |
| 4156 | for(i=1; i<n-1; i++){ |
| 4157 | m = radiusMidpoint(a[i+1],a[i],r, &isMid); |
| 4158 | pik_append_xy(p," Q ",a[i].x,a[i].y); |
| 4159 | pik_append_xy(p," ",m.x,m.y); |
| 4160 | if( !isMid ){ |
| 4161 | m = radiusMidpoint(a[i],a[i+1],r, &isMid); |
| 4162 | pik_append_xy(p," L ",m.x,m.y); |
| 4163 | } |
| 4164 | } |
| 4165 | pik_append_xy(p," L ",a[i].x,a[i].y); |
| 4166 | pik_append(p,"\" ",-1); |
| 4167 | pik_append_style(p,pObj,0); |
| 4168 | pik_append(p,"\" />\n", -1); |
| 4169 | } |
| 4170 | static void splineRender(Pik *p, PObj *pObj){ |
| 4171 | if( pObj->sw>0.0 ){ |
| 4172 | int n = pObj->nPath; |
| @@ -4804,12 +4809,12 @@ | |
| 4804 | jw = 0.0; |
| 4805 | } |
| 4806 | for(i=0; i<n; i++){ |
| 4807 | PToken *t = &aTxt[i]; |
| 4808 | PNum xtraFontScale = pik_font_scale(t); |
| 4809 | orig_y = pObj->ptAt.y; |
| 4810 | PNum nx = 0; |
| 4811 | y = 0; |
| 4812 | if( t->eCode & TP_ABOVE2 ) y += 0.5*hc + ha1 + 0.5*ha2; |
| 4813 | if( t->eCode & TP_ABOVE ) y += 0.5*hc + 0.5*ha1; |
| 4814 | if( t->eCode & TP_BELOW ) y -= 0.5*hc + 0.5*hb1; |
| 4815 | if( t->eCode & TP_BELOW2 ) y -= 0.5*hc + hb1 + 0.5*hb2; |
| @@ -5285,12 +5290,13 @@ | |
| 5285 | pNew->type->xInit(p, pNew); |
| 5286 | pik_add_txt(p, pStr, pStr->eCode); |
| 5287 | return pNew; |
| 5288 | } |
| 5289 | if( pId ){ |
| 5290 | pNew->errTok = *pId; |
| 5291 | const PClass *pClass = pik_find_class(pId); |
| 5292 | if( pClass ){ |
| 5293 | pNew->type = pClass; |
| 5294 | pNew->sw = pik_value(p, "thickness",9,0); |
| 5295 | pNew->fill = pik_value(p, "fill",4,0); |
| 5296 | pNew->color = pik_value(p, "color",5,0); |
| @@ -6721,18 +6727,18 @@ | |
| 6721 | bMoreToDo = 0; |
| 6722 | iThisLayer = iNextLayer; |
| 6723 | iNextLayer = 0x7fffffff; |
| 6724 | for(i=0; i<pList->n; i++){ |
| 6725 | PObj *pObj = pList->a[i]; |
| 6726 | if( pObj->iLayer>iThisLayer ){ |
| 6727 | if( pObj->iLayer<iNextLayer ) iNextLayer = pObj->iLayer; |
| 6728 | bMoreToDo = 1; |
| 6729 | continue; /* Defer until another round */ |
| 6730 | }else if( pObj->iLayer<iThisLayer ){ |
| 6731 | continue; |
| 6732 | } |
| 6733 | void (*xRender)(Pik*,PObj*); |
| 6734 | if( mDebug & 1 ) pik_elem_render(p, pObj); |
| 6735 | xRender = pObj->type->xRender; |
| 6736 | if( xRender ){ |
| 6737 | xRender(p, pObj); |
| 6738 | } |
| @@ -7774,6 +7780,6 @@ | |
| 7774 | |
| 7775 | |
| 7776 | #endif /* PIKCHR_TCL */ |
| 7777 | |
| 7778 | |
| 7779 | #line 7804 "pikchr.c" |
| 7780 |
| --- src/pikchr.c | |
| +++ src/pikchr.c | |
| @@ -3612,11 +3612,10 @@ | |
| 3612 | /* Methods for the "arrow" class */ |
| 3613 | static void arrowInit(Pik *p, PObj *pObj){ |
| 3614 | pObj->w = pik_value(p, "linewid",7,0); |
| 3615 | pObj->h = pik_value(p, "lineht",6,0); |
| 3616 | pObj->rad = pik_value(p, "linerad",7,0); |
| 3617 | pObj->rarrow = 1; |
| 3618 | } |
| 3619 | |
| 3620 | /* Methods for the "box" class */ |
| 3621 | static void boxInit(Pik *p, PObj *pObj){ |
| @@ -4033,11 +4032,10 @@ | |
| 4032 | /* Methods for the "line" class */ |
| 4033 | static void lineInit(Pik *p, PObj *pObj){ |
| 4034 | pObj->w = pik_value(p, "linewid",7,0); |
| 4035 | pObj->h = pik_value(p, "lineht",6,0); |
| 4036 | pObj->rad = pik_value(p, "linerad",7,0); |
| 4037 | } |
| 4038 | static PPoint lineOffset(Pik *p, PObj *pObj, int cp){ |
| 4039 | #if 0 |
| 4040 | /* In legacy PIC, the .center of an unclosed line is half way between |
| 4041 | ** its .start and .end. */ |
| @@ -4117,11 +4115,10 @@ | |
| 4115 | /* Methods for the "spline" class */ |
| 4116 | static void splineInit(Pik *p, PObj *pObj){ |
| 4117 | pObj->w = pik_value(p, "linewid",7,0); |
| 4118 | pObj->h = pik_value(p, "lineht",6,0); |
| 4119 | pObj->rad = 1000; |
| 4120 | } |
| 4121 | /* Return a point along the path from "f" to "t" that is r units |
| 4122 | ** prior to reaching "t", except if the path is less than 2*r total, |
| 4123 | ** return the midpoint. |
| 4124 | */ |
| @@ -4146,27 +4143,35 @@ | |
| 4143 | static void radiusPath(Pik *p, PObj *pObj, PNum r){ |
| 4144 | int i; |
| 4145 | int n = pObj->nPath; |
| 4146 | const PPoint *a = pObj->aPath; |
| 4147 | PPoint m; |
| 4148 | PPoint an = a[n-1]; |
| 4149 | int isMid = 0; |
| 4150 | int iLast = pObj->bClose ? n : n-1; |
| 4151 | |
| 4152 | pik_append_xy(p,"<path d=\"M", a[0].x, a[0].y); |
| 4153 | m = radiusMidpoint(a[0], a[1], r, &isMid); |
| 4154 | pik_append_xy(p," L ",m.x,m.y); |
| 4155 | for(i=1; i<iLast; i++){ |
| 4156 | an = i<n-1 ? a[i+1] : a[0]; |
| 4157 | m = radiusMidpoint(an,a[i],r, &isMid); |
| 4158 | pik_append_xy(p," Q ",a[i].x,a[i].y); |
| 4159 | pik_append_xy(p," ",m.x,m.y); |
| 4160 | if( !isMid ){ |
| 4161 | m = radiusMidpoint(a[i],an,r, &isMid); |
| 4162 | pik_append_xy(p," L ",m.x,m.y); |
| 4163 | } |
| 4164 | } |
| 4165 | pik_append_xy(p," L ",an.x,an.y); |
| 4166 | if( pObj->bClose ){ |
| 4167 | pik_append(p,"Z",1); |
| 4168 | }else{ |
| 4169 | pObj->fill = -1.0; |
| 4170 | } |
| 4171 | pik_append(p,"\" ",-1); |
| 4172 | pik_append_style(p,pObj,pObj->bClose); |
| 4173 | pik_append(p,"\" />\n", -1); |
| 4174 | } |
| 4175 | static void splineRender(Pik *p, PObj *pObj){ |
| 4176 | if( pObj->sw>0.0 ){ |
| 4177 | int n = pObj->nPath; |
| @@ -4804,12 +4809,12 @@ | |
| 4809 | jw = 0.0; |
| 4810 | } |
| 4811 | for(i=0; i<n; i++){ |
| 4812 | PToken *t = &aTxt[i]; |
| 4813 | PNum xtraFontScale = pik_font_scale(t); |
| 4814 | PNum nx = 0; |
| 4815 | orig_y = pObj->ptAt.y; |
| 4816 | y = 0; |
| 4817 | if( t->eCode & TP_ABOVE2 ) y += 0.5*hc + ha1 + 0.5*ha2; |
| 4818 | if( t->eCode & TP_ABOVE ) y += 0.5*hc + 0.5*ha1; |
| 4819 | if( t->eCode & TP_BELOW ) y -= 0.5*hc + 0.5*hb1; |
| 4820 | if( t->eCode & TP_BELOW2 ) y -= 0.5*hc + hb1 + 0.5*hb2; |
| @@ -5285,12 +5290,13 @@ | |
| 5290 | pNew->type->xInit(p, pNew); |
| 5291 | pik_add_txt(p, pStr, pStr->eCode); |
| 5292 | return pNew; |
| 5293 | } |
| 5294 | if( pId ){ |
| 5295 | const PClass *pClass; |
| 5296 | pNew->errTok = *pId; |
| 5297 | pClass = pik_find_class(pId); |
| 5298 | if( pClass ){ |
| 5299 | pNew->type = pClass; |
| 5300 | pNew->sw = pik_value(p, "thickness",9,0); |
| 5301 | pNew->fill = pik_value(p, "fill",4,0); |
| 5302 | pNew->color = pik_value(p, "color",5,0); |
| @@ -6721,18 +6727,18 @@ | |
| 6727 | bMoreToDo = 0; |
| 6728 | iThisLayer = iNextLayer; |
| 6729 | iNextLayer = 0x7fffffff; |
| 6730 | for(i=0; i<pList->n; i++){ |
| 6731 | PObj *pObj = pList->a[i]; |
| 6732 | void (*xRender)(Pik*,PObj*); |
| 6733 | if( pObj->iLayer>iThisLayer ){ |
| 6734 | if( pObj->iLayer<iNextLayer ) iNextLayer = pObj->iLayer; |
| 6735 | bMoreToDo = 1; |
| 6736 | continue; /* Defer until another round */ |
| 6737 | }else if( pObj->iLayer<iThisLayer ){ |
| 6738 | continue; |
| 6739 | } |
| 6740 | if( mDebug & 1 ) pik_elem_render(p, pObj); |
| 6741 | xRender = pObj->type->xRender; |
| 6742 | if( xRender ){ |
| 6743 | xRender(p, pObj); |
| 6744 | } |
| @@ -7774,6 +7780,6 @@ | |
| 7780 | |
| 7781 | |
| 7782 | #endif /* PIKCHR_TCL */ |
| 7783 | |
| 7784 | |
| 7785 | #line 7810 "pikchr.c" |
| 7786 |