| ︙ | | |
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
|
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
|
-
+
|
*/
struct PClass {
const char *zName; /* Name of class */
char isLine; /* True if a line class */
char eJust; /* Use box-style text justification */
void (*xInit)(Pik*,PElem*); /* Initializer */
void (*xNumProp)(Pik*,PElem*,PToken*); /* Value change notification */
void (*xCheck)(Pik*,PElem*); /* Checks to after parsing */
void (*xCheck)(Pik*,PElem*); /* Checks to do after parsing */
PPoint (*xChop)(Pik*,PElem*,PPoint*); /* Chopper */
PPoint (*xOffset)(Pik*,PElem*,int); /* Offset from .c to edge point */
void (*xFit)(Pik*,PElem*,PNum w,PNum h); /* Size to fit text */
void (*xRender)(Pik*,PElem*); /* Render */
};
|
| ︙ | | |
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
|
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
|
-
+
|
p->nOut += n;
p->zOut[p->nOut] = 0;
}
/*
** Append text to zOut with HTML characters escaped.
**
** * The space character is changed into non-breaking space (U+0080)
** * The space character is changed into non-breaking space (U+00a0)
** if mFlags has the 0x01 bit set. This is needed when outputting
** text to preserve leading and trailing whitespace. Turns out we
** cannot use as that is an HTML-ism and is not valid in XML.
**
** * The "&" character is changed into "&" if mFlags has the
** 0x02 bit set. This is needed when generating error message text.
**
|
| ︙ | | |
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
|
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
|
+
-
-
+
+
+
+
+
+
|
PNum ang = atan2(dy,dx)*-180/M_PI;
pik_append_num(p, " transform=\"rotate(", ang);
pik_append_xy(p, " ", x, orig_y);
pik_append(p,")\"",2);
}
}
pik_append(p," dominant-baseline=\"central\">",-1);
if( t->n>=2 && t->z[0]=='"' ){
z = t->z+1;
nz = t->n-2;
z = t->z+1;
nz = t->n-2;
}else{
z = t->z;
nz = t->n;
}
while( nz>0 ){
int j;
for(j=0; j<nz && z[j]!='\\'; j++){}
if( j ) pik_append_text(p, z, j, 1);
nz -= j+1;
z += j+1;
}
|
| ︙ | | |
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
|
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
|
-
+
|
}
/*
** Look up a color-name. Unlike other names in this program, the
** color-names are not case sensitive. So "DarkBlue" and "darkblue"
** and "DARKBLUE" all find the same value (139).
**
** If not found, return -1.0. Also post an error if p!=NULL.
** If not found, return -99.0. Also post an error if p!=NULL.
**
** Special color names "None" and "Off" return -1.0 without causing
** an error.
*/
static PNum pik_lookup_color(Pik *p, PToken *pId){
int first, last, mid, c = 0;
first = 0;
|
| ︙ | | |
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
|
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
|
-
+
-
+
|
if( c>0 ){
first = mid+1;
}else{
last = mid-1;
}
}
if( p ) pik_error(p, pId, "not a known color name");
return -1.0;
return -99.0;
}
/* Get the value of a variable.
**
** Search in order:
**
** * Application defined variables
** * Built-in variables
** * Color names
**
** If no such variable is found, throw an error.
*/
static PNum pik_get_var(Pik *p, PToken *pId){
int miss = 0;
PNum v = pik_value(p, pId->z, pId->n, &miss);
if( miss==0 ) return v;
v = pik_lookup_color(0, pId);
if( v>=0.0 ) return v;
if( v>-90.0 ) return v;
pik_error(p,pId,"no such variable");
return 0.0;
}
/* Convert a T_NTH token (ex: "2nd", "5th"} into a numeric value and
** return that value. Throw an error if the value is too big.
*/
|
| ︙ | | |
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
|
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
|
+
+
|
/* Render a list of elements
*/
void pik_elist_render(Pik *p, PEList *pEList){
int i;
int iNextLayer = 0;
int iThisLayer;
int bMoreToDo;
int miss = 0;
int mDebug = (int)pik_value(p, "debug", 5, 0);
PNum colorLabel;
do{
bMoreToDo = 0;
iThisLayer = iNextLayer;
iNextLayer = 0x7fffffff;
for(i=0; i<pEList->n; i++){
PElem *pElem = pEList->a[i];
if( pElem->iLayer>iThisLayer ){
|
| ︙ | | |
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
|
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
xRender(p, pElem);
}
if( pElem->pSublist ){
pik_elist_render(p, pElem->pSublist);
}
}
}while( bMoreToDo );
/* If the color_debug_label value is defined, then go through
** and paint a dot at every label location */
colorLabel = pik_value(p, "debug_label_color", 17, &miss);
if( miss==0 && colorLabel>=0.0 ){
PElem dot;
memset(&dot, 0, sizeof(dot));
dot.type = &noopClass;
dot.rad = 0.015;
dot.sw = 0.015;
dot.fill = colorLabel;
dot.color = colorLabel;
dot.nTxt = 1;
dot.aTxt[0].eCode = TP_ABOVE;
for(i=0; i<pEList->n; i++){
PElem *pElem = pEList->a[i];
if( pElem->zName==0 ) continue;
dot.ptAt = pElem->ptAt;
dot.aTxt[0].z = pElem->zName;
dot.aTxt[0].n = (int)strlen(pElem->zName);
dotRender(p, &dot);
}
}
}
/* Add all elements of the list pEList to the bounding box
*/
static void pik_bbox_add_elist(Pik *p, PEList *pEList, PNum wArrow){
int i;
for(i=0; i<pEList->n; i++){
|
| ︙ | | |
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
|
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
|
+
+
+
|
}
if( s.nErr==0 ){
memset(&token,0,sizeof(token));
token.z = zText;
pik_parser(&sParse, 0, token);
}
pik_parserFinalize(&sParse);
if( s.zOut==0 && s.nErr==0 ){
pik_append(&s, "<!-- empty pikchr diagram -->\n", -1);
}
while( s.pVar ){
PVar *pNext = s.pVar->pNext;
free(s.pVar);
s.pVar = pNext;
}
if( pnWidth ) *pnWidth = s.nErr ? -1 : s.wSVG;
if( pnHeight ) *pnHeight = s.nErr ? -1 : s.hSVG;
|
| ︙ | | |
7282
7283
7284
7285
7286
7287
7288
7289
|
7315
7316
7317
7318
7319
7320
7321
7322
|
-
+
|
if( !bSvgOnly ){
printf("</body></html>\n");
}
return 0;
}
#endif /* PIKCHR_SHELL */
#line 7314 "pikchr.c"
#line 7347 "pikchr.c"
|