aboutsummaryrefslogtreecommitdiffstats
path: root/include/graphf.lpg
diff options
context:
space:
mode:
authorJeffrey H. Kingston <jeff@it.usyd.edu.au>2010-09-14 20:38:56 +0000
committerJeffrey H. Kingston <jeff@it.usyd.edu.au>2010-09-14 20:38:56 +0000
commit7d292f1247e3287fb07a9a12377217ce8942cf09 (patch)
treeffe937ba04fb59a72b785040cf29db1476f7282a /include/graphf.lpg
parent68c155de3c3e83f53404288a318c5e29f0c4610f (diff)
downloadlout-7d292f1247e3287fb07a9a12377217ce8942cf09.tar.gz
Lout 3.29.
git-svn-id: http://svn.savannah.nongnu.org/svn/lout/trunk@27 9365b830-b601-4143-9ba8-b4a8e2c3339c
Diffstat (limited to 'include/graphf.lpg')
-rw-r--r--include/graphf.lpg100
1 files changed, 100 insertions, 0 deletions
diff --git a/include/graphf.lpg b/include/graphf.lpg
index 3c7edbc..5546586 100644
--- a/include/graphf.lpg
+++ b/include/graphf.lpg
@@ -123,6 +123,106 @@ lgraphdict begin
{ pop pop
} def
+% scale array elements by factor: <array> <factor> scalearray <array>
+/scalearray
+{
+ [ exch 3 2 roll
+ { exch dup 3 1 roll mul exch } forall
+ pop ]
+} def
+
+% sum array elements: <array> sumarray <number>
+/sumarray
+{
+ 0 exch { add } forall
+} def
+
+% begin a more complex line: <length> <dashlength> linebegin -
+/linebegin
+{
+ % (Entering linebegin) 2 debugprint
+ 20 dict begin
+ /dashlen exch 1 pt max def
+ /len exch def
+ /gap dashlen def
+ /halfgap dashlen 2 div def
+ /dash dashlen def
+ /halfdash dashlen 2 div def
+ /dot 0 def
+ % (Leaving linebegin) 0 debugprint
+} def
+% end a more complex line: <linecap> <cycle> <startpos> <stoppos> lineend -
+/lineend
+{
+ % (Entering lineend) 3 debugprint
+ /stoppos exch def
+ /startpos exch def
+ /cycle exch def
+ /linecap exch def
+ /stopposlen stoppos sumarray def
+ /startposlen startpos sumarray def
+ /cyclelen cycle sumarray def
+ /effectivelen len startposlen add stopposlen sub def
+ effectivelen 0 gt cyclelen 0 gt and
+ {
+ /repeats effectivelen cyclelen div ceiling def
+ /factor len repeats cyclelen mul startposlen sub stopposlen add div def
+ cycle factor scalearray startposlen factor mul setdash
+ linecap setlinecap stroke
+ } if
+ end
+ % (Leaving lineend) 0 debugprint
+} def
+
+% stroke a dotdashed line: <length> <dashlength> dotdashed -
+/dotdashed
+{
+ linebegin
+ 1 [dash gap dot gap] [] [dash]
+ lineend
+} def
+
+% stroke a dotcdashed line: <length> <dashlength> dotcdashed -
+/dotcdashed
+{
+ linebegin
+ 1 [dash gap dot gap] [halfdash] [halfdash]
+ lineend
+} def
+
+% stroke a dotdotdashed line: <length> <dashlength> dotdotdashed -
+/dotdotdashed
+{
+ linebegin
+ 1 [dash gap dot gap dot gap] [] [dash]
+ lineend
+} def
+
+% stroke a dotdotcdashed line: <length> <dashlength> dotdotcdashed -
+/dotdotcdashed
+{
+ linebegin
+ 1 [dash gap dot gap dot gap] [halfdash] [halfdash]
+ lineend
+} def
+
+% stroke a dotdotdotdashed line: <length> <dashlength> dotdotdotdashed -
+/dotdotdotdashed
+{
+ linebegin
+ 1 [dash gap dot gap dot gap dot gap] [] [dash]
+ lineend
+} def
+
+% stroke a dotdotdotcdashed line: <length> <dashlength> dotdotdotcdashed -
+/dotdotdotcdashed
+{
+ linebegin
+ 1 [dash gap dot gap dot gap dot gap] [halfdash] [halfdash]
+ lineend
+} def
+
+
% stroke a y histogram: - yhisto -
/yhisto
{ xprev yleft trpoint yextra sub moveto