Fossil SCM

Merge the enhanced Pikchr with diamond support into trunk.

drh 2024-02-08 18:02 trunk merge
Commit 7573b3f1e0734409b87f5844eba06a4d14e3c863432b4acd3c63bb8e33308713
+66 -1
--- extsrc/pikchr.c
+++ extsrc/pikchr.c
@@ -3577,10 +3577,12 @@
35773577
{ "color", 0.0 },
35783578
{ "cylht", 0.5 },
35793579
{ "cylrad", 0.075 },
35803580
{ "cylwid", 0.75 },
35813581
{ "dashwid", 0.05 },
3582
+ { "diamondht", 0.75 },
3583
+ { "diamondwid", 1.0 },
35823584
{ "dotrad", 0.015 },
35833585
{ "ellipseht", 0.5 },
35843586
{ "ellipsewid", 0.75 },
35853587
{ "fileht", 0.75 },
35863588
{ "filerad", 0.15 },
@@ -3957,10 +3959,62 @@
39573959
pik_append(p,"\" />\n", -1);
39583960
}
39593961
pik_append_txt(p, pObj, 0);
39603962
}
39613963
3964
+/* Methods for the "diamond" class */
3965
+static void diamondInit(Pik *p, PObj *pObj){
3966
+ pObj->w = pik_value(p, "diamondwid",10,0);
3967
+ pObj->h = pik_value(p, "diamondht",9,0);
3968
+}
3969
+/* Return offset from the center of the box to the compass point
3970
+** given by parameter cp */
3971
+static PPoint diamondOffset(Pik *p, PObj *pObj, int cp){
3972
+ PPoint pt = cZeroPoint;
3973
+ PNum w2 = 0.5*pObj->w;
3974
+ PNum w4 = 0.25*pObj->w;
3975
+ PNum h2 = 0.5*pObj->h;
3976
+ PNum h4 = 0.25*pObj->h;
3977
+ switch( cp ){
3978
+ case CP_C: break;
3979
+ case CP_N: pt.x = 0.0; pt.y = h2; break;
3980
+ case CP_NE: pt.x = w4; pt.y = h4; break;
3981
+ case CP_E: pt.x = w2; pt.y = 0.0; break;
3982
+ case CP_SE: pt.x = w4; pt.y = -h4; break;
3983
+ case CP_S: pt.x = 0.0; pt.y = -h2; break;
3984
+ case CP_SW: pt.x = -w4; pt.y = -h4; break;
3985
+ case CP_W: pt.x = -w2; pt.y = 0.0; break;
3986
+ case CP_NW: pt.x = -w4; pt.y = h4; break;
3987
+ default: assert(0);
3988
+ }
3989
+ UNUSED_PARAMETER(p);
3990
+ return pt;
3991
+}
3992
+static void diamondFit(Pik *p, PObj *pObj, PNum w, PNum h){
3993
+ if( pObj->w>0 && pObj->h>0 ){
3994
+ PNum x = pObj->w*h/pObj->h + w;
3995
+ PNum y = pObj->h*x/pObj->w;
3996
+ pObj->w = x;
3997
+ pObj->h = y;
3998
+ }
3999
+ UNUSED_PARAMETER(p);
4000
+}
4001
+static void diamondRender(Pik *p, PObj *pObj){
4002
+ PNum w2 = 0.5*pObj->w;
4003
+ PNum h2 = 0.5*pObj->h;
4004
+ PPoint pt = pObj->ptAt;
4005
+ if( pObj->sw>=0.0 ){
4006
+ pik_append_xy(p,"<path d=\"M", pt.x-w2,pt.y);
4007
+ pik_append_xy(p,"L", pt.x,pt.y-h2);
4008
+ pik_append_xy(p,"L", pt.x+w2,pt.y);
4009
+ pik_append_xy(p,"L", pt.x,pt.y+h2);
4010
+ pik_append(p,"Z\" ",-1);
4011
+ pik_append_style(p,pObj,3);
4012
+ pik_append(p,"\" />\n", -1);
4013
+ }
4014
+ pik_append_txt(p, pObj, 0);
4015
+}
39624016
39634017
39644018
/* Methods for the "ellipse" class */
39654019
static void ellipseInit(Pik *p, PObj *pObj){
39664020
pObj->w = pik_value(p, "ellipsewid",10,0);
@@ -4341,10 +4395,21 @@
43414395
/* xChop */ boxChop,
43424396
/* xOffset */ cylinderOffset,
43434397
/* xFit */ cylinderFit,
43444398
/* xRender */ cylinderRender
43454399
},
4400
+ { /* name */ "diamond",
4401
+ /* isline */ 0,
4402
+ /* eJust */ 0,
4403
+ /* xInit */ diamondInit,
4404
+ /* xNumProp */ 0,
4405
+ /* xCheck */ 0,
4406
+ /* xChop */ boxChop,
4407
+ /* xOffset */ diamondOffset,
4408
+ /* xFit */ diamondFit,
4409
+ /* xRender */ diamondRender
4410
+ },
43464411
{ /* name */ "dot",
43474412
/* isline */ 0,
43484413
/* eJust */ 0,
43494414
/* xInit */ dotInit,
43504415
/* xNumProp */ dotNumProp,
@@ -8143,6 +8208,6 @@
81438208
81448209
81458210
#endif /* PIKCHR_TCL */
81468211
81478212
8148
-#line 8173 "pikchr.c"
8213
+#line 8238 "pikchr.c"
81498214
--- extsrc/pikchr.c
+++ extsrc/pikchr.c
@@ -3577,10 +3577,12 @@
3577 { "color", 0.0 },
3578 { "cylht", 0.5 },
3579 { "cylrad", 0.075 },
3580 { "cylwid", 0.75 },
3581 { "dashwid", 0.05 },
 
 
3582 { "dotrad", 0.015 },
3583 { "ellipseht", 0.5 },
3584 { "ellipsewid", 0.75 },
3585 { "fileht", 0.75 },
3586 { "filerad", 0.15 },
@@ -3957,10 +3959,62 @@
3957 pik_append(p,"\" />\n", -1);
3958 }
3959 pik_append_txt(p, pObj, 0);
3960 }
3961
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3962
3963
3964 /* Methods for the "ellipse" class */
3965 static void ellipseInit(Pik *p, PObj *pObj){
3966 pObj->w = pik_value(p, "ellipsewid",10,0);
@@ -4341,10 +4395,21 @@
4341 /* xChop */ boxChop,
4342 /* xOffset */ cylinderOffset,
4343 /* xFit */ cylinderFit,
4344 /* xRender */ cylinderRender
4345 },
 
 
 
 
 
 
 
 
 
 
 
4346 { /* name */ "dot",
4347 /* isline */ 0,
4348 /* eJust */ 0,
4349 /* xInit */ dotInit,
4350 /* xNumProp */ dotNumProp,
@@ -8143,6 +8208,6 @@
8143
8144
8145 #endif /* PIKCHR_TCL */
8146
8147
8148 #line 8173 "pikchr.c"
8149
--- extsrc/pikchr.c
+++ extsrc/pikchr.c
@@ -3577,10 +3577,12 @@
3577 { "color", 0.0 },
3578 { "cylht", 0.5 },
3579 { "cylrad", 0.075 },
3580 { "cylwid", 0.75 },
3581 { "dashwid", 0.05 },
3582 { "diamondht", 0.75 },
3583 { "diamondwid", 1.0 },
3584 { "dotrad", 0.015 },
3585 { "ellipseht", 0.5 },
3586 { "ellipsewid", 0.75 },
3587 { "fileht", 0.75 },
3588 { "filerad", 0.15 },
@@ -3957,10 +3959,62 @@
3959 pik_append(p,"\" />\n", -1);
3960 }
3961 pik_append_txt(p, pObj, 0);
3962 }
3963
3964 /* Methods for the "diamond" class */
3965 static void diamondInit(Pik *p, PObj *pObj){
3966 pObj->w = pik_value(p, "diamondwid",10,0);
3967 pObj->h = pik_value(p, "diamondht",9,0);
3968 }
3969 /* Return offset from the center of the box to the compass point
3970 ** given by parameter cp */
3971 static PPoint diamondOffset(Pik *p, PObj *pObj, int cp){
3972 PPoint pt = cZeroPoint;
3973 PNum w2 = 0.5*pObj->w;
3974 PNum w4 = 0.25*pObj->w;
3975 PNum h2 = 0.5*pObj->h;
3976 PNum h4 = 0.25*pObj->h;
3977 switch( cp ){
3978 case CP_C: break;
3979 case CP_N: pt.x = 0.0; pt.y = h2; break;
3980 case CP_NE: pt.x = w4; pt.y = h4; break;
3981 case CP_E: pt.x = w2; pt.y = 0.0; break;
3982 case CP_SE: pt.x = w4; pt.y = -h4; break;
3983 case CP_S: pt.x = 0.0; pt.y = -h2; break;
3984 case CP_SW: pt.x = -w4; pt.y = -h4; break;
3985 case CP_W: pt.x = -w2; pt.y = 0.0; break;
3986 case CP_NW: pt.x = -w4; pt.y = h4; break;
3987 default: assert(0);
3988 }
3989 UNUSED_PARAMETER(p);
3990 return pt;
3991 }
3992 static void diamondFit(Pik *p, PObj *pObj, PNum w, PNum h){
3993 if( pObj->w>0 && pObj->h>0 ){
3994 PNum x = pObj->w*h/pObj->h + w;
3995 PNum y = pObj->h*x/pObj->w;
3996 pObj->w = x;
3997 pObj->h = y;
3998 }
3999 UNUSED_PARAMETER(p);
4000 }
4001 static void diamondRender(Pik *p, PObj *pObj){
4002 PNum w2 = 0.5*pObj->w;
4003 PNum h2 = 0.5*pObj->h;
4004 PPoint pt = pObj->ptAt;
4005 if( pObj->sw>=0.0 ){
4006 pik_append_xy(p,"<path d=\"M", pt.x-w2,pt.y);
4007 pik_append_xy(p,"L", pt.x,pt.y-h2);
4008 pik_append_xy(p,"L", pt.x+w2,pt.y);
4009 pik_append_xy(p,"L", pt.x,pt.y+h2);
4010 pik_append(p,"Z\" ",-1);
4011 pik_append_style(p,pObj,3);
4012 pik_append(p,"\" />\n", -1);
4013 }
4014 pik_append_txt(p, pObj, 0);
4015 }
4016
4017
4018 /* Methods for the "ellipse" class */
4019 static void ellipseInit(Pik *p, PObj *pObj){
4020 pObj->w = pik_value(p, "ellipsewid",10,0);
@@ -4341,10 +4395,21 @@
4395 /* xChop */ boxChop,
4396 /* xOffset */ cylinderOffset,
4397 /* xFit */ cylinderFit,
4398 /* xRender */ cylinderRender
4399 },
4400 { /* name */ "diamond",
4401 /* isline */ 0,
4402 /* eJust */ 0,
4403 /* xInit */ diamondInit,
4404 /* xNumProp */ 0,
4405 /* xCheck */ 0,
4406 /* xChop */ boxChop,
4407 /* xOffset */ diamondOffset,
4408 /* xFit */ diamondFit,
4409 /* xRender */ diamondRender
4410 },
4411 { /* name */ "dot",
4412 /* isline */ 0,
4413 /* eJust */ 0,
4414 /* xInit */ dotInit,
4415 /* xNumProp */ dotNumProp,
@@ -8143,6 +8208,6 @@
8208
8209
8210 #endif /* PIKCHR_TCL */
8211
8212
8213 #line 8238 "pikchr.c"
8214
--- extsrc/pikchr.wasm
+++ extsrc/pikchr.wasm
cannot compute difference between binary files
11
--- extsrc/pikchr.wasm
+++ extsrc/pikchr.wasm
0 annot compute difference between binary files
1
--- extsrc/pikchr.wasm
+++ extsrc/pikchr.wasm
0 annot compute difference between binary files
1

Keyboard Shortcuts

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