Fossil SCM

New pikchr.c with improved text layout for cylinders.

drh 2020-11-20 17:56 trunk
Commit 7c6656595789c8265942df07cc59e883f5afa581b4d6e4bb93b489e7b5526ee2
1 file changed +44 -14
+44 -14
--- src/pikchr.c
+++ src/pikchr.c
@@ -3756,11 +3756,11 @@
37563756
pik_append_arc(p, rad, rad, x0, y2);
37573757
if( y2>y1 ) pik_append_xy(p, "L", x0, y1);
37583758
pik_append_arc(p, rad, rad, x1, y0);
37593759
pik_append(p,"Z\" ",-1);
37603760
}
3761
- pik_append_style(p,pObj,1);
3761
+ pik_append_style(p,pObj,3);
37623762
pik_append(p,"\" />\n", -1);
37633763
}
37643764
pik_append_txt(p, pObj, 0);
37653765
}
37663766
@@ -3818,11 +3818,11 @@
38183818
PPoint pt = pObj->ptAt;
38193819
if( pObj->sw>0.0 ){
38203820
pik_append_x(p,"<circle cx=\"", pt.x, "\"");
38213821
pik_append_y(p," cy=\"", pt.y, "\"");
38223822
pik_append_dis(p," r=\"", r, "\" ");
3823
- pik_append_style(p,pObj,1);
3823
+ pik_append_style(p,pObj,3);
38243824
pik_append(p,"\" />\n", -1);
38253825
}
38263826
pik_append_txt(p, pObj, 0);
38273827
}
38283828
@@ -3848,11 +3848,11 @@
38483848
pik_append_arc(p,w2,rad,pt.x+w2,pt.y-h2+rad);
38493849
pik_append_xy(p,"L", pt.x+w2,pt.y+h2-rad);
38503850
pik_append_arc(p,w2,rad,pt.x-w2,pt.y+h2-rad);
38513851
pik_append_arc(p,w2,rad,pt.x+w2,pt.y+h2-rad);
38523852
pik_append(p,"\" ",-1);
3853
- pik_append_style(p,pObj,1);
3853
+ pik_append_style(p,pObj,3);
38543854
pik_append(p,"\" />\n", -1);
38553855
}
38563856
pik_append_txt(p, pObj, 0);
38573857
}
38583858
static PPoint cylinderOffset(Pik *p, PObj *pObj, int cp){
@@ -3910,11 +3910,11 @@
39103910
PPoint pt = pObj->ptAt;
39113911
if( pObj->sw>0.0 ){
39123912
pik_append_x(p,"<circle cx=\"", pt.x, "\"");
39133913
pik_append_y(p," cy=\"", pt.y, "\"");
39143914
pik_append_dis(p," r=\"", r, "\"");
3915
- pik_append_style(p,pObj,1);
3915
+ pik_append_style(p,pObj,2);
39163916
pik_append(p,"\" />\n", -1);
39173917
}
39183918
pik_append_txt(p, pObj, 0);
39193919
}
39203920
@@ -3969,11 +3969,11 @@
39693969
if( pObj->sw>0.0 ){
39703970
pik_append_x(p,"<ellipse cx=\"", pt.x, "\"");
39713971
pik_append_y(p," cy=\"", pt.y, "\"");
39723972
pik_append_dis(p," rx=\"", w/2.0, "\"");
39733973
pik_append_dis(p," ry=\"", h/2.0, "\" ");
3974
- pik_append_style(p,pObj,1);
3974
+ pik_append_style(p,pObj,3);
39753975
pik_append(p,"\" />\n", -1);
39763976
}
39773977
pik_append_txt(p, pObj, 0);
39783978
}
39793979
@@ -4081,11 +4081,11 @@
40814081
pik_append(p,"Z",1);
40824082
}else{
40834083
pObj->fill = -1.0;
40844084
}
40854085
pik_append(p,"\" ",-1);
4086
- pik_append_style(p,pObj,pObj->bClose);
4086
+ pik_append_style(p,pObj,pObj->bClose?3:0);
40874087
pik_append(p,"\" />\n", -1);
40884088
}
40894089
pik_append_txt(p, pObj, 0);
40904090
}
40914091
@@ -4181,11 +4181,11 @@
41814181
pik_append(p,"Z",1);
41824182
}else{
41834183
pObj->fill = -1.0;
41844184
}
41854185
pik_append(p,"\" ",-1);
4186
- pik_append_style(p,pObj,pObj->bClose);
4186
+ pik_append_style(p,pObj,pObj->bClose?3:0);
41874187
pik_append(p,"\" />\n", -1);
41884188
}
41894189
static void splineRender(Pik *p, PObj *pObj){
41904190
if( pObj->sw>0.0 ){
41914191
int n = pObj->nPath;
@@ -4569,10 +4569,13 @@
45694569
pik_append(p, buf, -1);
45704570
}
45714571
45724572
/*
45734573
** Invert the RGB color so that it is appropriate for dark mode.
4574
+** Variable x hold the initial color. The color is intended for use
4575
+** as a background color if isBg is true, and as a foreground color
4576
+** if isBg is false.
45744577
*/
45754578
static int pik_color_to_dark_mode(int x, int isBg){
45764579
int r, g, b;
45774580
int mn, mx;
45784581
x = 0xffffff - x;
@@ -4634,10 +4637,18 @@
46344637
char buf[200];
46354638
snprintf(buf, sizeof(buf)-1, "%s%g%s", z1, p->rScale*v, z2);
46364639
buf[sizeof(buf)-1] = 0;
46374640
pik_append(p, buf, -1);
46384641
}
4642
+
4643
+/* Append a color specification to the output.
4644
+**
4645
+** In PIKCHR_DARK_MODE, the color is inverted. The "bg" flags indicates that
4646
+** the color is intended for use as a background color if true, or as a
4647
+** foreground color if false. The distinction only matters for color
4648
+** inversions in PIKCHR_DARK_MODE.
4649
+*/
46394650
static void pik_append_clr(Pik *p,const char *z1,PNum v,const char *z2,int bg){
46404651
char buf[200];
46414652
int x = (int)v;
46424653
int r, g, b;
46434654
if( x==0 && p->fgcolor>0 && !bg ){
@@ -4668,25 +4679,39 @@
46684679
pik_append(p, buf, -1);
46694680
}
46704681
46714682
/* Append a style="..." text. But, leave the quote unterminated, in case
46724683
** the caller wants to add some more.
4684
+**
4685
+** eFill is non-zero to fill in the background, or 0 if no fill should
4686
+** occur. Non-zero values of eFill determine the "bg" flag to pik_append_clr()
4687
+** for cases when pObj->fill==pObj->color
4688
+**
4689
+** 1 fill is background, and color is foreground.
4690
+** 2 fill and color are both foreground. (Used by "dot" objects)
4691
+** 3 fill and color are both background. (Used by most other objs)
46734692
*/
4674
-static void pik_append_style(Pik *p, PObj *pObj, int bFill){
4693
+static void pik_append_style(Pik *p, PObj *pObj, int eFill){
4694
+ int clrIsBg = 0;
46754695
pik_append(p, " style=\"", -1);
4676
- if( pObj->fill>=0 && bFill ){
4677
- pik_append_clr(p, "fill:", pObj->fill, ";",1);
4696
+ if( pObj->fill>=0 && eFill ){
4697
+ int fillIsBg = 1;
4698
+ if( pObj->fill==pObj->color ){
4699
+ if( eFill==2 ) fillIsBg = 0;
4700
+ if( eFill==3 ) clrIsBg = 1;
4701
+ }
4702
+ pik_append_clr(p, "fill:", pObj->fill, ";", fillIsBg);
46784703
}else{
46794704
pik_append(p,"fill:none;",-1);
46804705
}
46814706
if( pObj->sw>0.0 && pObj->color>=0.0 ){
46824707
PNum sw = pObj->sw;
46834708
pik_append_dis(p, "stroke-width:", sw, ";");
46844709
if( pObj->nPath>2 && pObj->rad<=pObj->sw ){
46854710
pik_append(p, "stroke-linejoin:round;", -1);
46864711
}
4687
- pik_append_clr(p, "stroke:",pObj->color,";",0);
4712
+ pik_append_clr(p, "stroke:",pObj->color,";",clrIsBg);
46884713
if( pObj->dotted>0.0 ){
46894714
PNum v = pObj->dotted;
46904715
if( sw<2.1/p->rScale ) sw = 2.1/p->rScale;
46914716
pik_append_dis(p,"stroke-dasharray:",sw,"");
46924717
pik_append_dis(p,",",v,";");
@@ -4802,10 +4827,11 @@
48024827
PNum ha2 = 0.0; /* Height of the top row of text */
48034828
PNum ha1 = 0.0; /* Height of the second "above" row */
48044829
PNum hc = 0.0; /* Height of the center row */
48054830
PNum hb1 = 0.0; /* Height of the first "below" row of text */
48064831
PNum hb2 = 0.0; /* Height of the second "below" row */
4832
+ PNum yBase = 0.0;
48074833
int n, i, nz;
48084834
PNum x, y, orig_y, s;
48094835
const char *z;
48104836
PToken *aTxt;
48114837
unsigned allMask = 0;
@@ -4815,11 +4841,15 @@
48154841
aTxt = pObj->aTxt;
48164842
n = pObj->nTxt;
48174843
pik_txt_vertical_layout(pObj);
48184844
x = pObj->ptAt.x;
48194845
for(i=0; i<n; i++) allMask |= pObj->aTxt[i].eCode;
4820
- if( pObj->type->isLine ) hc = pObj->sw*1.5;
4846
+ if( pObj->type->isLine ){
4847
+ hc = pObj->sw*1.5;
4848
+ }else if( pObj->type->xInit==cylinderInit ){
4849
+ yBase = -0.75*pObj->rad;
4850
+ }
48214851
if( allMask & TP_CENTER ){
48224852
for(i=0; i<n; i++){
48234853
if( pObj->aTxt[i].eCode & TP_CENTER ){
48244854
s = pik_font_scale(pObj->aTxt+i);
48254855
if( hc<s*p->charHeight ) hc = s*p->charHeight;
@@ -4866,11 +4896,11 @@
48664896
for(i=0; i<n; i++){
48674897
PToken *t = &aTxt[i];
48684898
PNum xtraFontScale = pik_font_scale(t);
48694899
PNum nx = 0;
48704900
orig_y = pObj->ptAt.y;
4871
- y = 0;
4901
+ y = yBase;
48724902
if( t->eCode & TP_ABOVE2 ) y += 0.5*hc + ha1 + 0.5*ha2;
48734903
if( t->eCode & TP_ABOVE ) y += 0.5*hc + 0.5*ha1;
48744904
if( t->eCode & TP_BELOW ) y -= 0.5*hc + 0.5*hb1;
48754905
if( t->eCode & TP_BELOW2 ) y -= 0.5*hc + hb1 + 0.5*hb2;
48764906
if( t->eCode & TP_LJUST ) nx -= jw;
@@ -7852,6 +7882,6 @@
78527882
78537883
78547884
#endif /* PIKCHR_TCL */
78557885
78567886
7857
-#line 7882 "pikchr.c"
7887
+#line 7912 "pikchr.c"
78587888
--- src/pikchr.c
+++ src/pikchr.c
@@ -3756,11 +3756,11 @@
3756 pik_append_arc(p, rad, rad, x0, y2);
3757 if( y2>y1 ) pik_append_xy(p, "L", x0, y1);
3758 pik_append_arc(p, rad, rad, x1, y0);
3759 pik_append(p,"Z\" ",-1);
3760 }
3761 pik_append_style(p,pObj,1);
3762 pik_append(p,"\" />\n", -1);
3763 }
3764 pik_append_txt(p, pObj, 0);
3765 }
3766
@@ -3818,11 +3818,11 @@
3818 PPoint pt = pObj->ptAt;
3819 if( pObj->sw>0.0 ){
3820 pik_append_x(p,"<circle cx=\"", pt.x, "\"");
3821 pik_append_y(p," cy=\"", pt.y, "\"");
3822 pik_append_dis(p," r=\"", r, "\" ");
3823 pik_append_style(p,pObj,1);
3824 pik_append(p,"\" />\n", -1);
3825 }
3826 pik_append_txt(p, pObj, 0);
3827 }
3828
@@ -3848,11 +3848,11 @@
3848 pik_append_arc(p,w2,rad,pt.x+w2,pt.y-h2+rad);
3849 pik_append_xy(p,"L", pt.x+w2,pt.y+h2-rad);
3850 pik_append_arc(p,w2,rad,pt.x-w2,pt.y+h2-rad);
3851 pik_append_arc(p,w2,rad,pt.x+w2,pt.y+h2-rad);
3852 pik_append(p,"\" ",-1);
3853 pik_append_style(p,pObj,1);
3854 pik_append(p,"\" />\n", -1);
3855 }
3856 pik_append_txt(p, pObj, 0);
3857 }
3858 static PPoint cylinderOffset(Pik *p, PObj *pObj, int cp){
@@ -3910,11 +3910,11 @@
3910 PPoint pt = pObj->ptAt;
3911 if( pObj->sw>0.0 ){
3912 pik_append_x(p,"<circle cx=\"", pt.x, "\"");
3913 pik_append_y(p," cy=\"", pt.y, "\"");
3914 pik_append_dis(p," r=\"", r, "\"");
3915 pik_append_style(p,pObj,1);
3916 pik_append(p,"\" />\n", -1);
3917 }
3918 pik_append_txt(p, pObj, 0);
3919 }
3920
@@ -3969,11 +3969,11 @@
3969 if( pObj->sw>0.0 ){
3970 pik_append_x(p,"<ellipse cx=\"", pt.x, "\"");
3971 pik_append_y(p," cy=\"", pt.y, "\"");
3972 pik_append_dis(p," rx=\"", w/2.0, "\"");
3973 pik_append_dis(p," ry=\"", h/2.0, "\" ");
3974 pik_append_style(p,pObj,1);
3975 pik_append(p,"\" />\n", -1);
3976 }
3977 pik_append_txt(p, pObj, 0);
3978 }
3979
@@ -4081,11 +4081,11 @@
4081 pik_append(p,"Z",1);
4082 }else{
4083 pObj->fill = -1.0;
4084 }
4085 pik_append(p,"\" ",-1);
4086 pik_append_style(p,pObj,pObj->bClose);
4087 pik_append(p,"\" />\n", -1);
4088 }
4089 pik_append_txt(p, pObj, 0);
4090 }
4091
@@ -4181,11 +4181,11 @@
4181 pik_append(p,"Z",1);
4182 }else{
4183 pObj->fill = -1.0;
4184 }
4185 pik_append(p,"\" ",-1);
4186 pik_append_style(p,pObj,pObj->bClose);
4187 pik_append(p,"\" />\n", -1);
4188 }
4189 static void splineRender(Pik *p, PObj *pObj){
4190 if( pObj->sw>0.0 ){
4191 int n = pObj->nPath;
@@ -4569,10 +4569,13 @@
4569 pik_append(p, buf, -1);
4570 }
4571
4572 /*
4573 ** Invert the RGB color so that it is appropriate for dark mode.
 
 
 
4574 */
4575 static int pik_color_to_dark_mode(int x, int isBg){
4576 int r, g, b;
4577 int mn, mx;
4578 x = 0xffffff - x;
@@ -4634,10 +4637,18 @@
4634 char buf[200];
4635 snprintf(buf, sizeof(buf)-1, "%s%g%s", z1, p->rScale*v, z2);
4636 buf[sizeof(buf)-1] = 0;
4637 pik_append(p, buf, -1);
4638 }
 
 
 
 
 
 
 
 
4639 static void pik_append_clr(Pik *p,const char *z1,PNum v,const char *z2,int bg){
4640 char buf[200];
4641 int x = (int)v;
4642 int r, g, b;
4643 if( x==0 && p->fgcolor>0 && !bg ){
@@ -4668,25 +4679,39 @@
4668 pik_append(p, buf, -1);
4669 }
4670
4671 /* Append a style="..." text. But, leave the quote unterminated, in case
4672 ** the caller wants to add some more.
 
 
 
 
 
 
 
 
4673 */
4674 static void pik_append_style(Pik *p, PObj *pObj, int bFill){
 
4675 pik_append(p, " style=\"", -1);
4676 if( pObj->fill>=0 && bFill ){
4677 pik_append_clr(p, "fill:", pObj->fill, ";",1);
 
 
 
 
 
4678 }else{
4679 pik_append(p,"fill:none;",-1);
4680 }
4681 if( pObj->sw>0.0 && pObj->color>=0.0 ){
4682 PNum sw = pObj->sw;
4683 pik_append_dis(p, "stroke-width:", sw, ";");
4684 if( pObj->nPath>2 && pObj->rad<=pObj->sw ){
4685 pik_append(p, "stroke-linejoin:round;", -1);
4686 }
4687 pik_append_clr(p, "stroke:",pObj->color,";",0);
4688 if( pObj->dotted>0.0 ){
4689 PNum v = pObj->dotted;
4690 if( sw<2.1/p->rScale ) sw = 2.1/p->rScale;
4691 pik_append_dis(p,"stroke-dasharray:",sw,"");
4692 pik_append_dis(p,",",v,";");
@@ -4802,10 +4827,11 @@
4802 PNum ha2 = 0.0; /* Height of the top row of text */
4803 PNum ha1 = 0.0; /* Height of the second "above" row */
4804 PNum hc = 0.0; /* Height of the center row */
4805 PNum hb1 = 0.0; /* Height of the first "below" row of text */
4806 PNum hb2 = 0.0; /* Height of the second "below" row */
 
4807 int n, i, nz;
4808 PNum x, y, orig_y, s;
4809 const char *z;
4810 PToken *aTxt;
4811 unsigned allMask = 0;
@@ -4815,11 +4841,15 @@
4815 aTxt = pObj->aTxt;
4816 n = pObj->nTxt;
4817 pik_txt_vertical_layout(pObj);
4818 x = pObj->ptAt.x;
4819 for(i=0; i<n; i++) allMask |= pObj->aTxt[i].eCode;
4820 if( pObj->type->isLine ) hc = pObj->sw*1.5;
 
 
 
 
4821 if( allMask & TP_CENTER ){
4822 for(i=0; i<n; i++){
4823 if( pObj->aTxt[i].eCode & TP_CENTER ){
4824 s = pik_font_scale(pObj->aTxt+i);
4825 if( hc<s*p->charHeight ) hc = s*p->charHeight;
@@ -4866,11 +4896,11 @@
4866 for(i=0; i<n; i++){
4867 PToken *t = &aTxt[i];
4868 PNum xtraFontScale = pik_font_scale(t);
4869 PNum nx = 0;
4870 orig_y = pObj->ptAt.y;
4871 y = 0;
4872 if( t->eCode & TP_ABOVE2 ) y += 0.5*hc + ha1 + 0.5*ha2;
4873 if( t->eCode & TP_ABOVE ) y += 0.5*hc + 0.5*ha1;
4874 if( t->eCode & TP_BELOW ) y -= 0.5*hc + 0.5*hb1;
4875 if( t->eCode & TP_BELOW2 ) y -= 0.5*hc + hb1 + 0.5*hb2;
4876 if( t->eCode & TP_LJUST ) nx -= jw;
@@ -7852,6 +7882,6 @@
7852
7853
7854 #endif /* PIKCHR_TCL */
7855
7856
7857 #line 7882 "pikchr.c"
7858
--- src/pikchr.c
+++ src/pikchr.c
@@ -3756,11 +3756,11 @@
3756 pik_append_arc(p, rad, rad, x0, y2);
3757 if( y2>y1 ) pik_append_xy(p, "L", x0, y1);
3758 pik_append_arc(p, rad, rad, x1, y0);
3759 pik_append(p,"Z\" ",-1);
3760 }
3761 pik_append_style(p,pObj,3);
3762 pik_append(p,"\" />\n", -1);
3763 }
3764 pik_append_txt(p, pObj, 0);
3765 }
3766
@@ -3818,11 +3818,11 @@
3818 PPoint pt = pObj->ptAt;
3819 if( pObj->sw>0.0 ){
3820 pik_append_x(p,"<circle cx=\"", pt.x, "\"");
3821 pik_append_y(p," cy=\"", pt.y, "\"");
3822 pik_append_dis(p," r=\"", r, "\" ");
3823 pik_append_style(p,pObj,3);
3824 pik_append(p,"\" />\n", -1);
3825 }
3826 pik_append_txt(p, pObj, 0);
3827 }
3828
@@ -3848,11 +3848,11 @@
3848 pik_append_arc(p,w2,rad,pt.x+w2,pt.y-h2+rad);
3849 pik_append_xy(p,"L", pt.x+w2,pt.y+h2-rad);
3850 pik_append_arc(p,w2,rad,pt.x-w2,pt.y+h2-rad);
3851 pik_append_arc(p,w2,rad,pt.x+w2,pt.y+h2-rad);
3852 pik_append(p,"\" ",-1);
3853 pik_append_style(p,pObj,3);
3854 pik_append(p,"\" />\n", -1);
3855 }
3856 pik_append_txt(p, pObj, 0);
3857 }
3858 static PPoint cylinderOffset(Pik *p, PObj *pObj, int cp){
@@ -3910,11 +3910,11 @@
3910 PPoint pt = pObj->ptAt;
3911 if( pObj->sw>0.0 ){
3912 pik_append_x(p,"<circle cx=\"", pt.x, "\"");
3913 pik_append_y(p," cy=\"", pt.y, "\"");
3914 pik_append_dis(p," r=\"", r, "\"");
3915 pik_append_style(p,pObj,2);
3916 pik_append(p,"\" />\n", -1);
3917 }
3918 pik_append_txt(p, pObj, 0);
3919 }
3920
@@ -3969,11 +3969,11 @@
3969 if( pObj->sw>0.0 ){
3970 pik_append_x(p,"<ellipse cx=\"", pt.x, "\"");
3971 pik_append_y(p," cy=\"", pt.y, "\"");
3972 pik_append_dis(p," rx=\"", w/2.0, "\"");
3973 pik_append_dis(p," ry=\"", h/2.0, "\" ");
3974 pik_append_style(p,pObj,3);
3975 pik_append(p,"\" />\n", -1);
3976 }
3977 pik_append_txt(p, pObj, 0);
3978 }
3979
@@ -4081,11 +4081,11 @@
4081 pik_append(p,"Z",1);
4082 }else{
4083 pObj->fill = -1.0;
4084 }
4085 pik_append(p,"\" ",-1);
4086 pik_append_style(p,pObj,pObj->bClose?3:0);
4087 pik_append(p,"\" />\n", -1);
4088 }
4089 pik_append_txt(p, pObj, 0);
4090 }
4091
@@ -4181,11 +4181,11 @@
4181 pik_append(p,"Z",1);
4182 }else{
4183 pObj->fill = -1.0;
4184 }
4185 pik_append(p,"\" ",-1);
4186 pik_append_style(p,pObj,pObj->bClose?3:0);
4187 pik_append(p,"\" />\n", -1);
4188 }
4189 static void splineRender(Pik *p, PObj *pObj){
4190 if( pObj->sw>0.0 ){
4191 int n = pObj->nPath;
@@ -4569,10 +4569,13 @@
4569 pik_append(p, buf, -1);
4570 }
4571
4572 /*
4573 ** Invert the RGB color so that it is appropriate for dark mode.
4574 ** Variable x hold the initial color. The color is intended for use
4575 ** as a background color if isBg is true, and as a foreground color
4576 ** if isBg is false.
4577 */
4578 static int pik_color_to_dark_mode(int x, int isBg){
4579 int r, g, b;
4580 int mn, mx;
4581 x = 0xffffff - x;
@@ -4634,10 +4637,18 @@
4637 char buf[200];
4638 snprintf(buf, sizeof(buf)-1, "%s%g%s", z1, p->rScale*v, z2);
4639 buf[sizeof(buf)-1] = 0;
4640 pik_append(p, buf, -1);
4641 }
4642
4643 /* Append a color specification to the output.
4644 **
4645 ** In PIKCHR_DARK_MODE, the color is inverted. The "bg" flags indicates that
4646 ** the color is intended for use as a background color if true, or as a
4647 ** foreground color if false. The distinction only matters for color
4648 ** inversions in PIKCHR_DARK_MODE.
4649 */
4650 static void pik_append_clr(Pik *p,const char *z1,PNum v,const char *z2,int bg){
4651 char buf[200];
4652 int x = (int)v;
4653 int r, g, b;
4654 if( x==0 && p->fgcolor>0 && !bg ){
@@ -4668,25 +4679,39 @@
4679 pik_append(p, buf, -1);
4680 }
4681
4682 /* Append a style="..." text. But, leave the quote unterminated, in case
4683 ** the caller wants to add some more.
4684 **
4685 ** eFill is non-zero to fill in the background, or 0 if no fill should
4686 ** occur. Non-zero values of eFill determine the "bg" flag to pik_append_clr()
4687 ** for cases when pObj->fill==pObj->color
4688 **
4689 ** 1 fill is background, and color is foreground.
4690 ** 2 fill and color are both foreground. (Used by "dot" objects)
4691 ** 3 fill and color are both background. (Used by most other objs)
4692 */
4693 static void pik_append_style(Pik *p, PObj *pObj, int eFill){
4694 int clrIsBg = 0;
4695 pik_append(p, " style=\"", -1);
4696 if( pObj->fill>=0 && eFill ){
4697 int fillIsBg = 1;
4698 if( pObj->fill==pObj->color ){
4699 if( eFill==2 ) fillIsBg = 0;
4700 if( eFill==3 ) clrIsBg = 1;
4701 }
4702 pik_append_clr(p, "fill:", pObj->fill, ";", fillIsBg);
4703 }else{
4704 pik_append(p,"fill:none;",-1);
4705 }
4706 if( pObj->sw>0.0 && pObj->color>=0.0 ){
4707 PNum sw = pObj->sw;
4708 pik_append_dis(p, "stroke-width:", sw, ";");
4709 if( pObj->nPath>2 && pObj->rad<=pObj->sw ){
4710 pik_append(p, "stroke-linejoin:round;", -1);
4711 }
4712 pik_append_clr(p, "stroke:",pObj->color,";",clrIsBg);
4713 if( pObj->dotted>0.0 ){
4714 PNum v = pObj->dotted;
4715 if( sw<2.1/p->rScale ) sw = 2.1/p->rScale;
4716 pik_append_dis(p,"stroke-dasharray:",sw,"");
4717 pik_append_dis(p,",",v,";");
@@ -4802,10 +4827,11 @@
4827 PNum ha2 = 0.0; /* Height of the top row of text */
4828 PNum ha1 = 0.0; /* Height of the second "above" row */
4829 PNum hc = 0.0; /* Height of the center row */
4830 PNum hb1 = 0.0; /* Height of the first "below" row of text */
4831 PNum hb2 = 0.0; /* Height of the second "below" row */
4832 PNum yBase = 0.0;
4833 int n, i, nz;
4834 PNum x, y, orig_y, s;
4835 const char *z;
4836 PToken *aTxt;
4837 unsigned allMask = 0;
@@ -4815,11 +4841,15 @@
4841 aTxt = pObj->aTxt;
4842 n = pObj->nTxt;
4843 pik_txt_vertical_layout(pObj);
4844 x = pObj->ptAt.x;
4845 for(i=0; i<n; i++) allMask |= pObj->aTxt[i].eCode;
4846 if( pObj->type->isLine ){
4847 hc = pObj->sw*1.5;
4848 }else if( pObj->type->xInit==cylinderInit ){
4849 yBase = -0.75*pObj->rad;
4850 }
4851 if( allMask & TP_CENTER ){
4852 for(i=0; i<n; i++){
4853 if( pObj->aTxt[i].eCode & TP_CENTER ){
4854 s = pik_font_scale(pObj->aTxt+i);
4855 if( hc<s*p->charHeight ) hc = s*p->charHeight;
@@ -4866,11 +4896,11 @@
4896 for(i=0; i<n; i++){
4897 PToken *t = &aTxt[i];
4898 PNum xtraFontScale = pik_font_scale(t);
4899 PNum nx = 0;
4900 orig_y = pObj->ptAt.y;
4901 y = yBase;
4902 if( t->eCode & TP_ABOVE2 ) y += 0.5*hc + ha1 + 0.5*ha2;
4903 if( t->eCode & TP_ABOVE ) y += 0.5*hc + 0.5*ha1;
4904 if( t->eCode & TP_BELOW ) y -= 0.5*hc + 0.5*hb1;
4905 if( t->eCode & TP_BELOW2 ) y -= 0.5*hc + hb1 + 0.5*hb2;
4906 if( t->eCode & TP_LJUST ) nx -= jw;
@@ -7852,6 +7882,6 @@
7882
7883
7884 #endif /* PIKCHR_TCL */
7885
7886
7887 #line 7912 "pikchr.c"
7888

Keyboard Shortcuts

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