Fossil SCM

New pikchr.c that fixes an additional problem with "to" terms on line paths and that ensures that "dot" objects to not change the exit point.

drh 2020-09-14 17:03 trunk
Commit 863d272205172935214f12bb14ad5ea1a7f4773d6359972e4666b16bc9798537
1 file changed +23 -13
+23 -13
--- src/pikchr.c
+++ src/pikchr.c
@@ -3769,10 +3769,20 @@
37693769
break;
37703770
case T_FILL:
37713771
pElem->color = pElem->fill;
37723772
break;
37733773
}
3774
+}
3775
+static void dotCheck(Pik *p, PElem *pElem){
3776
+ pElem->w = pElem->h = 0;
3777
+ pik_bbox_addellipse(&pElem->bbox, pElem->ptAt.x, pElem->ptAt.y,
3778
+ pElem->rad, pElem->rad);
3779
+}
3780
+static PPoint dotOffset(Pik *p, PElem *pElem, int cp){
3781
+ PPoint zero;
3782
+ zero.x = zero.y = 0;
3783
+ return zero;
37743784
}
37753785
static void dotRender(Pik *p, PElem *pElem){
37763786
PNum r = pElem->rad;
37773787
PPoint pt = pElem->ptAt;
37783788
if( pElem->sw>0.0 ){
@@ -4155,13 +4165,13 @@
41554165
{ /* name */ "dot",
41564166
/* isline */ 0,
41574167
/* eJust */ 0,
41584168
/* xInit */ dotInit,
41594169
/* xNumProp */ dotNumProp,
4160
- /* xCheck */ 0,
4170
+ /* xCheck */ dotCheck,
41614171
/* xChop */ circleChop,
4162
- /* xOffset */ ellipseOffset,
4172
+ /* xOffset */ dotOffset,
41634173
/* xFit */ 0,
41644174
/* xRender */ dotRender
41654175
},
41664176
{ /* name */ "ellipse",
41674177
/* isline */ 0,
@@ -5413,11 +5423,11 @@
54135423
}
54145424
if( pElem->bClose ){
54155425
pik_error(p, pTk, "polygon is closed");
54165426
return;
54175427
}
5418
- if( p->mTPath==3 || p->thenFlag ){
5428
+ if( n==0 || p->mTPath==3 || p->thenFlag ){
54195429
n = pik_next_rpath(p, pTk);
54205430
}
54215431
p->aTPath[n] = *pPt;
54225432
p->mTPath = 3;
54235433
}
@@ -6082,15 +6092,17 @@
60826092
PNum dx, dy;
60836093
60846094
if( p->nErr ) return;
60856095
60866096
/* Position block elements */
6087
- ofst = pik_elem_offset(p, pElem, pElem->eWith);
6088
- dx = (pElem->with.x - ofst.x) - pElem->ptAt.x;
6089
- dy = (pElem->with.y - ofst.y) - pElem->ptAt.y;
6090
- if( dx!=0 || dy!=0 ){
6091
- pik_elem_move(pElem, dx, dy);
6097
+ if( pElem->type->isLine==0 ){
6098
+ ofst = pik_elem_offset(p, pElem, pElem->eWith);
6099
+ dx = (pElem->with.x - ofst.x) - pElem->ptAt.x;
6100
+ dy = (pElem->with.y - ofst.y) - pElem->ptAt.y;
6101
+ if( dx!=0 || dy!=0 ){
6102
+ pik_elem_move(pElem, dx, dy);
6103
+ }
60926104
}
60936105
60946106
/* For a line object with no movement specified, a single movement
60956107
** of the default length in the current direction
60966108
*/
@@ -6186,14 +6198,12 @@
61866198
default: pElem->ptExit.x += w2; break;
61876199
case DIR_LEFT: pElem->ptExit.x -= w2; break;
61886200
case DIR_UP: pElem->ptExit.y += h2; break;
61896201
case DIR_DOWN: pElem->ptExit.y -= h2; break;
61906202
}
6191
- pElem->bbox.sw.x = pElem->ptAt.x - w2;
6192
- pElem->bbox.sw.y = pElem->ptAt.y - h2;
6193
- pElem->bbox.ne.x = pElem->ptAt.x + w2;
6194
- pElem->bbox.ne.y = pElem->ptAt.y + h2;
6203
+ pik_bbox_add_xy(&pElem->bbox, pElem->ptAt.x - w2, pElem->ptAt.y - h2);
6204
+ pik_bbox_add_xy(&pElem->bbox, pElem->ptAt.x + w2, pElem->ptAt.y + h2);
61956205
}
61966206
p->eDir = pElem->outDir;
61976207
}
61986208
61996209
/* Show basic information about each element as a comment in the
@@ -6989,6 +6999,6 @@
69896999
printf("</body></html>\n");
69907000
return 0;
69917001
}
69927002
#endif /* PIKCHR_SHELL */
69937003
6994
-#line 7019 "pikchr.c"
7004
+#line 7029 "pikchr.c"
69957005
--- src/pikchr.c
+++ src/pikchr.c
@@ -3769,10 +3769,20 @@
3769 break;
3770 case T_FILL:
3771 pElem->color = pElem->fill;
3772 break;
3773 }
 
 
 
 
 
 
 
 
 
 
3774 }
3775 static void dotRender(Pik *p, PElem *pElem){
3776 PNum r = pElem->rad;
3777 PPoint pt = pElem->ptAt;
3778 if( pElem->sw>0.0 ){
@@ -4155,13 +4165,13 @@
4155 { /* name */ "dot",
4156 /* isline */ 0,
4157 /* eJust */ 0,
4158 /* xInit */ dotInit,
4159 /* xNumProp */ dotNumProp,
4160 /* xCheck */ 0,
4161 /* xChop */ circleChop,
4162 /* xOffset */ ellipseOffset,
4163 /* xFit */ 0,
4164 /* xRender */ dotRender
4165 },
4166 { /* name */ "ellipse",
4167 /* isline */ 0,
@@ -5413,11 +5423,11 @@
5413 }
5414 if( pElem->bClose ){
5415 pik_error(p, pTk, "polygon is closed");
5416 return;
5417 }
5418 if( p->mTPath==3 || p->thenFlag ){
5419 n = pik_next_rpath(p, pTk);
5420 }
5421 p->aTPath[n] = *pPt;
5422 p->mTPath = 3;
5423 }
@@ -6082,15 +6092,17 @@
6082 PNum dx, dy;
6083
6084 if( p->nErr ) return;
6085
6086 /* Position block elements */
6087 ofst = pik_elem_offset(p, pElem, pElem->eWith);
6088 dx = (pElem->with.x - ofst.x) - pElem->ptAt.x;
6089 dy = (pElem->with.y - ofst.y) - pElem->ptAt.y;
6090 if( dx!=0 || dy!=0 ){
6091 pik_elem_move(pElem, dx, dy);
 
 
6092 }
6093
6094 /* For a line object with no movement specified, a single movement
6095 ** of the default length in the current direction
6096 */
@@ -6186,14 +6198,12 @@
6186 default: pElem->ptExit.x += w2; break;
6187 case DIR_LEFT: pElem->ptExit.x -= w2; break;
6188 case DIR_UP: pElem->ptExit.y += h2; break;
6189 case DIR_DOWN: pElem->ptExit.y -= h2; break;
6190 }
6191 pElem->bbox.sw.x = pElem->ptAt.x - w2;
6192 pElem->bbox.sw.y = pElem->ptAt.y - h2;
6193 pElem->bbox.ne.x = pElem->ptAt.x + w2;
6194 pElem->bbox.ne.y = pElem->ptAt.y + h2;
6195 }
6196 p->eDir = pElem->outDir;
6197 }
6198
6199 /* Show basic information about each element as a comment in the
@@ -6989,6 +6999,6 @@
6989 printf("</body></html>\n");
6990 return 0;
6991 }
6992 #endif /* PIKCHR_SHELL */
6993
6994 #line 7019 "pikchr.c"
6995
--- src/pikchr.c
+++ src/pikchr.c
@@ -3769,10 +3769,20 @@
3769 break;
3770 case T_FILL:
3771 pElem->color = pElem->fill;
3772 break;
3773 }
3774 }
3775 static void dotCheck(Pik *p, PElem *pElem){
3776 pElem->w = pElem->h = 0;
3777 pik_bbox_addellipse(&pElem->bbox, pElem->ptAt.x, pElem->ptAt.y,
3778 pElem->rad, pElem->rad);
3779 }
3780 static PPoint dotOffset(Pik *p, PElem *pElem, int cp){
3781 PPoint zero;
3782 zero.x = zero.y = 0;
3783 return zero;
3784 }
3785 static void dotRender(Pik *p, PElem *pElem){
3786 PNum r = pElem->rad;
3787 PPoint pt = pElem->ptAt;
3788 if( pElem->sw>0.0 ){
@@ -4155,13 +4165,13 @@
4165 { /* name */ "dot",
4166 /* isline */ 0,
4167 /* eJust */ 0,
4168 /* xInit */ dotInit,
4169 /* xNumProp */ dotNumProp,
4170 /* xCheck */ dotCheck,
4171 /* xChop */ circleChop,
4172 /* xOffset */ dotOffset,
4173 /* xFit */ 0,
4174 /* xRender */ dotRender
4175 },
4176 { /* name */ "ellipse",
4177 /* isline */ 0,
@@ -5413,11 +5423,11 @@
5423 }
5424 if( pElem->bClose ){
5425 pik_error(p, pTk, "polygon is closed");
5426 return;
5427 }
5428 if( n==0 || p->mTPath==3 || p->thenFlag ){
5429 n = pik_next_rpath(p, pTk);
5430 }
5431 p->aTPath[n] = *pPt;
5432 p->mTPath = 3;
5433 }
@@ -6082,15 +6092,17 @@
6092 PNum dx, dy;
6093
6094 if( p->nErr ) return;
6095
6096 /* Position block elements */
6097 if( pElem->type->isLine==0 ){
6098 ofst = pik_elem_offset(p, pElem, pElem->eWith);
6099 dx = (pElem->with.x - ofst.x) - pElem->ptAt.x;
6100 dy = (pElem->with.y - ofst.y) - pElem->ptAt.y;
6101 if( dx!=0 || dy!=0 ){
6102 pik_elem_move(pElem, dx, dy);
6103 }
6104 }
6105
6106 /* For a line object with no movement specified, a single movement
6107 ** of the default length in the current direction
6108 */
@@ -6186,14 +6198,12 @@
6198 default: pElem->ptExit.x += w2; break;
6199 case DIR_LEFT: pElem->ptExit.x -= w2; break;
6200 case DIR_UP: pElem->ptExit.y += h2; break;
6201 case DIR_DOWN: pElem->ptExit.y -= h2; break;
6202 }
6203 pik_bbox_add_xy(&pElem->bbox, pElem->ptAt.x - w2, pElem->ptAt.y - h2);
6204 pik_bbox_add_xy(&pElem->bbox, pElem->ptAt.x + w2, pElem->ptAt.y + h2);
 
 
6205 }
6206 p->eDir = pElem->outDir;
6207 }
6208
6209 /* Show basic information about each element as a comment in the
@@ -6989,6 +6999,6 @@
6999 printf("</body></html>\n");
7000 return 0;
7001 }
7002 #endif /* PIKCHR_SHELL */
7003
7004 #line 7029 "pikchr.c"
7005

Keyboard Shortcuts

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