summaryrefslogtreecommitdiff
path: root/metapost/context/base/mpxl/mp-lmtx.mpxl
diff options
context:
space:
mode:
Diffstat (limited to 'metapost/context/base/mpxl/mp-lmtx.mpxl')
-rw-r--r--metapost/context/base/mpxl/mp-lmtx.mpxl127
1 files changed, 66 insertions, 61 deletions
diff --git a/metapost/context/base/mpxl/mp-lmtx.mpxl b/metapost/context/base/mpxl/mp-lmtx.mpxl
index 89c39ee89..be4ae716b 100644
--- a/metapost/context/base/mpxl/mp-lmtx.mpxl
+++ b/metapost/context/base/mpxl/mp-lmtx.mpxl
@@ -284,6 +284,8 @@ vardef lmt_do_outline =
kind := "r" ;
elseif kind = "fillup" :
kind := "u" ;
+ elseif kind = "path" :
+ kind := "p" ;
fi ;
currentoutlinetext := currentoutlinetext + 1 ;
lua.mp.mf_outline_text(
@@ -1166,67 +1168,67 @@ def lmt_do_chart_legend =
fi ;
enddef ;
-vardef lmt_do_chart_circle =
- image (
- lmt_do_chart_start("chart:circle") ;
- if (nofsamplesets > 0) and (nofsamples > 0) :
- nofsamplesets := 1 ;
- save p, r, s, first, last, total, factor, n, percentage ;
- path p, r, s[] ; boolean percentage ;
- percentage := getparameter "percentage" ;
- total := 0 ;
- for i = 1 upto nofsamples :
- total := total + getparameter "samples" (1) i ; % () is needed else 1i
- endfor ;
- factor := 100/total ;
- first := 0 ;
- p := fullcircle ysized (height) ;
- r := origin -- (2*height,0) ;
- for i = 1 upto nofsamples :
- fillcolor := getparameter "fillcolors" i ;
- value := (getparameter "samples" (1) i) * factor ;
- last := first + (360/100) * value ;
- s[i] := ((p cutbefore (r rotated first)) cutafter (r rotated last)) ;
- % fill
- % (if innerradius > 0 : reverse (s[i] scaled innerradius) else : origin fi) -- s[i] -- cycle
- % withcolor fillcolor
- % ;
- fill origin -- s[i] -- cycle withcolor fillcolor ;
- first := last ;
- endfor ;
- if linewidth > 0 :
- if drawcolor = "" :
- drawcolor := backgroundcolor ;
- fi ;
- for i = 1 upto nofsamples :
- interim linecap := butt ;
- draw origin -- (point 0 of s[i]) withpen pencircle scaled linewidth withcolor drawcolor ;
- draw origin -- (point length(s[i]) of s[i]) withpen pencircle scaled linewidth withcolor drawcolor ;
- endfor ;
- fi ;
- if getparameter "showlabels" :
- first := 0 ;
- for i = 1 upto nofsamples :
- value := getparameter "samples" (1) i ;
- last := first + (360/100) * value * factor ;
- draw lmt_do_chart_text (s,i,value)
- shifted ((labelfraction*(height/2),0) rotated ((first+last)/2)) ;
- first := last ;
- endfor ;
- fi ;
- lmt_do_chart_legend ;
- n := getparameter "originsize" ;
- if n > 0 :
- fill fullcircle scaled n withcolor "white" ;
- fi ;
- n := getparameter "innerradius" ;
- if n > 0 :
- fill fullcircle scaled n withcolor "white" ;
- fi ;
- fi ;
- lmt_do_chart_stop ;
- )
-enddef ;
+% vardef lmt_do_chart_circle =
+% image (
+% lmt_do_chart_start("chart:circle") ;
+% if (nofsamplesets > 0) and (nofsamples > 0) :
+% nofsamplesets := 1 ;
+% save p, r, s, first, last, total, factor, n, percentage ;
+% path p, r, s[] ; boolean percentage ;
+% percentage := getparameter "percentage" ;
+% total := 0 ;
+% for i = 1 upto nofsamples :
+% total := total + getparameter "samples" (1) i ; % () is needed else 1i
+% endfor ;
+% factor := 100/total ;
+% first := 0 ;
+% p := fullcircle ysized (height) ;
+% r := origin -- (2*height,0) ;
+% for i = 1 upto nofsamples :
+% fillcolor := getparameter "fillcolors" i ;
+% value := (getparameter "samples" (1) i) * factor ;
+% last := first + (360/100) * value ;
+% s[i] := ((p cutbefore (r rotated first)) cutafter (r rotated last)) ;
+% % fill
+% % (if innerradius > 0 : reverse (s[i] scaled innerradius) else : origin fi) -- s[i] -- cycle
+% % withcolor fillcolor
+% % ;
+% fill origin -- s[i] -- cycle withcolor fillcolor ;
+% first := last ;
+% endfor ;
+% if linewidth > 0 :
+% if drawcolor = "" :
+% drawcolor := backgroundcolor ;
+% fi ;
+% for i = 1 upto nofsamples :
+% interim linecap := butt ;
+% draw origin -- (point 0 of s[i]) withpen pencircle scaled linewidth withcolor drawcolor ;
+% draw origin -- (point length(s[i]) of s[i]) withpen pencircle scaled linewidth withcolor drawcolor ;
+% endfor ;
+% fi ;
+% if getparameter "showlabels" :
+% first := 0 ;
+% for i = 1 upto nofsamples :
+% value := getparameter "samples" (1) i ;
+% last := first + (360/100) * value * factor ;
+% draw lmt_do_chart_text (s,i,value)
+% shifted ((labelfraction*(height/2),0) rotated ((first+last)/2)) ;
+% first := last ;
+% endfor ;
+% fi ;
+% lmt_do_chart_legend ;
+% n := getparameter "originsize" ;
+% if n > 0 :
+% fill fullcircle scaled n withcolor "white" ;
+% fi ;
+% n := getparameter "innerradius" ;
+% if n > 0 :
+% fill fullcircle scaled n withcolor "white" ;
+% fi ;
+% fi ;
+% lmt_do_chart_stop ;
+% )
+% enddef ;
vardef lmt_do_chart_circle =
image (
@@ -1253,6 +1255,9 @@ vardef lmt_do_chart_circle =
for i = 1 upto nofsamples :
fillcolor := getparameter "fillcolors" i ;
value := (getparameter "samples" (1) i) * factor ;
+ if (value > -eps) and (value < eps) :
+ value := eps ; % otherwise weird effects with zero
+ fi ;
last := first if clockwise : - else : + fi (360/100) * value ;
s[i] := ((p cutbefore (r rotated first)) cutafter (r rotated last)) ;
% fill