Fossil SCM

Update to the latest pikchr.c that fixes issues with the "close" attribute.

drh 2020-10-29 02:06 trunk
Commit c9bc2b4a8d3d849277b4f635a9a0957a7411b11c1ee4811e216242ea2b3ea6c3
1 file changed +18 -12
+18 -12
--- src/pikchr.c
+++ src/pikchr.c
@@ -3612,11 +3612,10 @@
36123612
/* Methods for the "arrow" class */
36133613
static void arrowInit(Pik *p, PObj *pObj){
36143614
pObj->w = pik_value(p, "linewid",7,0);
36153615
pObj->h = pik_value(p, "lineht",6,0);
36163616
pObj->rad = pik_value(p, "linerad",7,0);
3617
- pObj->fill = -1.0;
36183617
pObj->rarrow = 1;
36193618
}
36203619
36213620
/* Methods for the "box" class */
36223621
static void boxInit(Pik *p, PObj *pObj){
@@ -4033,11 +4032,10 @@
40334032
/* Methods for the "line" class */
40344033
static void lineInit(Pik *p, PObj *pObj){
40354034
pObj->w = pik_value(p, "linewid",7,0);
40364035
pObj->h = pik_value(p, "lineht",6,0);
40374036
pObj->rad = pik_value(p, "linerad",7,0);
4038
- pObj->fill = -1.0;
40394037
}
40404038
static PPoint lineOffset(Pik *p, PObj *pObj, int cp){
40414039
#if 0
40424040
/* In legacy PIC, the .center of an unclosed line is half way between
40434041
** its .start and .end. */
@@ -4117,11 +4115,10 @@
41174115
/* Methods for the "spline" class */
41184116
static void splineInit(Pik *p, PObj *pObj){
41194117
pObj->w = pik_value(p, "linewid",7,0);
41204118
pObj->h = pik_value(p, "lineht",6,0);
41214119
pObj->rad = 1000;
4122
- pObj->fill = -1.0; /* Disable fill by default */
41234120
}
41244121
/* Return a point along the path from "f" to "t" that is r units
41254122
** prior to reaching "t", except if the path is less than 2*r total,
41264123
** return the midpoint.
41274124
*/
@@ -4146,27 +4143,35 @@
41464143
static void radiusPath(Pik *p, PObj *pObj, PNum r){
41474144
int i;
41484145
int n = pObj->nPath;
41494146
const PPoint *a = pObj->aPath;
41504147
PPoint m;
4148
+ PPoint an = a[n-1];
41514149
int isMid = 0;
4150
+ int iLast = pObj->bClose ? n : n-1;
41524151
41534152
pik_append_xy(p,"<path d=\"M", a[0].x, a[0].y);
41544153
m = radiusMidpoint(a[0], a[1], r, &isMid);
41554154
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);
41584158
pik_append_xy(p," Q ",a[i].x,a[i].y);
41594159
pik_append_xy(p," ",m.x,m.y);
41604160
if( !isMid ){
4161
- m = radiusMidpoint(a[i],a[i+1],r, &isMid);
4161
+ m = radiusMidpoint(a[i],an,r, &isMid);
41624162
pik_append_xy(p," L ",m.x,m.y);
41634163
}
41644164
}
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
+ }
41664171
pik_append(p,"\" ",-1);
4167
- pik_append_style(p,pObj,0);
4172
+ pik_append_style(p,pObj,pObj->bClose);
41684173
pik_append(p,"\" />\n", -1);
41694174
}
41704175
static void splineRender(Pik *p, PObj *pObj){
41714176
if( pObj->sw>0.0 ){
41724177
int n = pObj->nPath;
@@ -4804,12 +4809,12 @@
48044809
jw = 0.0;
48054810
}
48064811
for(i=0; i<n; i++){
48074812
PToken *t = &aTxt[i];
48084813
PNum xtraFontScale = pik_font_scale(t);
4809
- orig_y = pObj->ptAt.y;
48104814
PNum nx = 0;
4815
+ orig_y = pObj->ptAt.y;
48114816
y = 0;
48124817
if( t->eCode & TP_ABOVE2 ) y += 0.5*hc + ha1 + 0.5*ha2;
48134818
if( t->eCode & TP_ABOVE ) y += 0.5*hc + 0.5*ha1;
48144819
if( t->eCode & TP_BELOW ) y -= 0.5*hc + 0.5*hb1;
48154820
if( t->eCode & TP_BELOW2 ) y -= 0.5*hc + hb1 + 0.5*hb2;
@@ -5285,12 +5290,13 @@
52855290
pNew->type->xInit(p, pNew);
52865291
pik_add_txt(p, pStr, pStr->eCode);
52875292
return pNew;
52885293
}
52895294
if( pId ){
5295
+ const PClass *pClass;
52905296
pNew->errTok = *pId;
5291
- const PClass *pClass = pik_find_class(pId);
5297
+ pClass = pik_find_class(pId);
52925298
if( pClass ){
52935299
pNew->type = pClass;
52945300
pNew->sw = pik_value(p, "thickness",9,0);
52955301
pNew->fill = pik_value(p, "fill",4,0);
52965302
pNew->color = pik_value(p, "color",5,0);
@@ -6721,18 +6727,18 @@
67216727
bMoreToDo = 0;
67226728
iThisLayer = iNextLayer;
67236729
iNextLayer = 0x7fffffff;
67246730
for(i=0; i<pList->n; i++){
67256731
PObj *pObj = pList->a[i];
6732
+ void (*xRender)(Pik*,PObj*);
67266733
if( pObj->iLayer>iThisLayer ){
67276734
if( pObj->iLayer<iNextLayer ) iNextLayer = pObj->iLayer;
67286735
bMoreToDo = 1;
67296736
continue; /* Defer until another round */
67306737
}else if( pObj->iLayer<iThisLayer ){
67316738
continue;
67326739
}
6733
- void (*xRender)(Pik*,PObj*);
67346740
if( mDebug & 1 ) pik_elem_render(p, pObj);
67356741
xRender = pObj->type->xRender;
67366742
if( xRender ){
67376743
xRender(p, pObj);
67386744
}
@@ -7774,6 +7780,6 @@
77747780
77757781
77767782
#endif /* PIKCHR_TCL */
77777783
77787784
7779
-#line 7804 "pikchr.c"
7785
+#line 7810 "pikchr.c"
77807786
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button