diff options
Diffstat (limited to 'metapost')
-rw-r--r-- | metapost/context/mp-core.mp | 24 | ||||
-rw-r--r-- | metapost/context/mp-grph.mp | 190 | ||||
-rw-r--r-- | metapost/context/mp-spec.mp | 7 | ||||
-rw-r--r-- | metapost/context/mp-tool.mp | 9 |
4 files changed, 133 insertions, 97 deletions
diff --git a/metapost/context/mp-core.mp b/metapost/context/mp-core.mp index 80e3a8eb5..5f1341a69 100644 --- a/metapost/context/mp-core.mp +++ b/metapost/context/mp-core.mp @@ -16,8 +16,8 @@ if known context_core : endinput ; fi ; boolean context_core ; context_core := true ; -pair lxy[], rxy[], cxy[], llxy[], lrxy[], ulxy[], urxy[] ; -path pxy[] ; +pair lxy[], rxy[], cxy[], llxy[], lrxy[], ulxy[], urxy[] ; +path pxy[] ; numeric hxy[], wxy[], dxy[], nxy[] ; def box_found (expr n,x,y,w,h,d) = @@ -397,6 +397,10 @@ if local_multi_par_area : TextAreas[1] := TextAreas[0] ; TextColumns[1] := TextColumns[0] ; nxy[fpos] := nxy[tpos] := nxy[wpos] := nxy[ppos] := RealPageNumber ; + +%draw TextColumns[1] withcolor green ; +%draw TextAreas[1] withcolor green ; + elseif ignore_multi_par_page : RealPageNumber := fn ; nxy[fpos] := nxy[tpos] := nxy[wpos] := nxy[ppos] := RealPageNumber ; @@ -600,7 +604,6 @@ fi ; % _pa_ := (xpart _pa_,ypart llcorner multipar); %fi ; - (xpart _ur_ + par_hang_indent, ypart _ur_) -- (xpart _ur_ + par_hang_indent, ypart _pa_) -- (xpart _ur_, ypart _pa_) @@ -836,6 +839,19 @@ fi ; fi ; + elseif (nxy[tpos]=RealPageNumber) : + + % outside text area, fall back / test on: pascal werkboek + + multipar := + + llxy[fpos] -- + lrxy[tpos] -- + urxy[tpos] -- + ulxy[fpos] -- cycle ; + + save_multipar (i,1,multipar) ; + else : multipar := if obey_multi_par_hang : @@ -899,7 +915,7 @@ snapped_multi_pos(ulxy[tpos]) -- save_multipar (i,3,multipar) ; else : - + % handled later fi ; diff --git a/metapost/context/mp-grph.mp b/metapost/context/mp-grph.mp index 8c94d68d0..957a60ec8 100644 --- a/metapost/context/mp-grph.mp +++ b/metapost/context/mp-grph.mp @@ -2,116 +2,124 @@ %D [ file=mp-grph.mp, %D version=2000.12.14, %D title=\CONTEXT\ \METAPOST\ graphics, -%D subtitle=graphic text support, +%D subtitle=graphic text support, %D author=Hans Hagen, %D date=\currentdate, %D copyright={PRAGMA / Hans Hagen \& Ton Otten}] %C %C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See licen-en.pdf for -%C details. +%C therefore copyrighted by \PRAGMA. See licen-en.pdf for +%C details. %D Under construction. -if unknown context_tool : input mp-tool ; fi ; -if known context_grph : endinput ; fi ; +if unknown context_tool : input mp-tool ; fi ; +if known context_grph : endinput ; fi ; -boolean context_grph ; context_grph := true ; +boolean context_grph ; context_grph := true ; -string CRLF ; CRLF := char 10 & char 13 ; +string CRLF ; CRLF := char 10 & char 13 ; -picture _currentpicture_ ; +picture _currentpicture_ ; def beginfig (expr c) = begingroup - charcode := c ; - resetfig ; - scantokens extra_beginfig ; -enddef ; + charcode := c ; + resetfig ; + scantokens extra_beginfig ; +enddef ; def resetfig = - clearxy ; - clearit ; + clearxy ; + clearit ; clearpen ; pickup defaultpen ; - interim linecap := linecap ; - interim linejoin := linejoin ; - interim miterlimit := miterlimit ; - save _background_ ; color _background_ ; _background_ := background ; + interim linecap := linecap ; + interim linejoin := linejoin ; + interim miterlimit := miterlimit ; + save _background_ ; color _background_ ; _background_ := background ; save background ; color background ; background := _background_ ; drawoptions () ; enddef ; -def protectgraphicmacros = - save showtext ; +def protectgraphicmacros = + save showtext ; save beginfig ; let beginfig = begingraphictextfig ; save endfig ; let endfig = endgraphictextfig ; - save end ; let end = relax ; - interim prologues := prologues ; + save end ; let end = relax ; + interim prologues := prologues ; resetfig ; -enddef ; +enddef ; -numeric currentgraphictext ; currentgraphictext := 0 ; +numeric currentgraphictext ; currentgraphictext := 0 ; string graphictextformat ; graphictextformat := "plain" ; -string graphictextstring ; graphictextstring := "" ; +string graphictextstring ; graphictextstring := "" ; string graphictextfile ; graphictextfile := "dummy.mpo" ; -def savegraphictext (expr str) = +def savegraphictext (expr str) = graphictextfile := jobname & ".mpo" ; if (graphictextstring<>"") : write graphictextstring to graphictextfile ; - graphictextstring := "" ; - fi ; + graphictextstring := "" ; + fi ; write str to graphictextfile ; - let erasegraphictextfile = relax ; -enddef ; + let erasegraphictextfile = relax ; +enddef ; -def erasegraphictextfile = +def erasegraphictextfile = graphictextfile := jobname & ".mpo" ; write EOF to graphictextfile ; - let erasegraphictextfile = relax ; -enddef ; + let erasegraphictextfile = relax ; +enddef ; -extra_beginfig := extra_beginfig & " erasegraphictextfile ;" ; +extra_beginfig := extra_beginfig & " erasegraphictextfile ;" ; def begingraphictextfig (expr n) = foundpicture := n ; scratchpicture := nullpicture ; enddef ; def endgraphictextfig = - if foundpicture = currentgraphictext : - expandafter endinput - else : - scratchpicture := nullpicture ; + if foundpicture = currentgraphictext : + expandafter endinput + else : + scratchpicture := nullpicture ; fi ; enddef ; -def loadfigure primary filename = - doloadfigure (filename) -enddef ; +def loadfigure primary filename = + doloadfigure (filename) +enddef ; def doloadfigure (expr filename) text figureattributes = begingroup ; - save figurenumber, figurepicture, number ; - numeric figurenumber ; figurenumber := 1 ; - picture figurepicture ; figurepicture := currentpicture ; - def number primary n = hide(figurenumber := n) enddef ; - protectgraphicmacros ; - % defaults + save figurenumber, figurepicture, number, fixedplace ; + numeric figurenumber ; figurenumber := 0 ; + boolean figureshift ; figureshift := true ; + picture figurepicture ; figurepicture := currentpicture ; + def number primary n = hide(figurenumber := n) enddef ; + def fixedplace = hide(figureshift := false) enddef ; + protectgraphicmacros ; + % defaults interim linecap := rounded ; interim linejoin := rounded ; interim miterlimit := 10 ; - % - currentpicture := nullpicture ; - def beginfig (expr n) = - currentpicture := nullpicture ; - if figurenumber=n : let endfig = endinput ; fi ; - enddef ; - let endfig = relax ; - readfile(filename) ; - currentpicture := currentpicture shifted -llcorner currentpicture ; - addto figurepicture also currentpicture figureattributes ; - currentpicture := figurepicture ; + % + currentpicture := nullpicture ; + draw fullcircle figureattributes ; % expand number + currentpicture := nullpicture ; + def beginfig (expr n) = + currentpicture := nullpicture ; + if (figurenumber=n) or (figurenumber=0) : + let endfig = endinput ; + fi ; + enddef ; + let endfig = relax ; + readfile(filename) ; + if figureshift : + currentpicture := currentpicture shifted -llcorner currentpicture ; + fi ; + addto figurepicture also currentpicture figureattributes ; + currentpicture := figurepicture ; endgroup ; enddef ; @@ -128,7 +136,7 @@ def dographictext (expr t) = fi ; currentgraphictext := currentgraphictext + 1 ; savegraphictext ("\startTEXpage[scale=10000]" & t & "\stopTEXpage") ; - dofinishgraphictext + dofinishgraphictext enddef ; def redographictext primary t = @@ -139,37 +147,37 @@ def regraphictext (expr t) = begingroup ; save currentgraphictext ; numeric currentgraphictext ; currentgraphictext := t ; - dofinishgraphictext + dofinishgraphictext enddef ; -%D Believe it or not, but it took me half a day to uncover +%D Believe it or not, but it took me half a day to uncover %D the following neccessity: -%D -%D \starttypen -%D save withfillcolor, withdrawcolor ; -%D \stoptypen -%D -%D When we have more than one graphictext, these will be -%D defined after the first graphic. For some obscure reason, +%D +%D \starttypen +%D save withfillcolor, withdrawcolor ; +%D \stoptypen +%D +%D When we have more than one graphictext, these will be +%D defined after the first graphic. For some obscure reason, %D this means that in the next graphic they will be called, but -%D afterwards the data and boolean are not set. Don't ask me -%D why. +%D afterwards the data and boolean are not set. Don't ask me +%D why. def dofinishgraphictext text x_op_x = protectgraphicmacros ; - interim linecap := butt ; % normally rounded - interim linejoin := mitered ; % normally rounded - interim miterlimit := 10 ; % todo + interim linecap := butt ; % normally rounded + interim linejoin := mitered ; % normally rounded + interim miterlimit := 10 ; % todo let normalwithshade = withshade ; save foundpicture, scratchpicture, str ; save fill, draw, withshade, reversefill, outlinefill ; save withfillcolor, withdrawcolor ; % quite important numeric foundpicture ; picture scratchpicture ; string str ; def draw expr p = - % the first, naive implementation was: + % the first, naive implementation was: % addto scratchpicture doublepath p withpen currentpen ; - % but it is better to turn lines into fills - addto scratchpicture contour boundingbox + % but it is better to turn lines into fills + addto scratchpicture contour boundingbox image (addto currentpicture doublepath p withpen currentpen) ; enddef ; def fill expr p = @@ -247,22 +255,22 @@ def dofinishgraphictext text x_op_x = endgroup ; enddef ; -def resetgraphictextdirective = - graphictextstring := "" ; -enddef ; +def resetgraphictextdirective = + graphictextstring := "" ; +enddef ; -def graphictextdirective text t = - graphictextstring := graphictextstring & t & CRLF ; -enddef ; +def graphictextdirective text t = + graphictextstring := graphictextstring & t & CRLF ; +enddef ; -endinput +endinput % example -input mp-grph ; +input mp-grph ; - graphictextformat := "context" ; -% graphictextformat := "plain" ; + graphictextformat := "context" ; +% graphictextformat := "plain" ; % graphictextformat := "latex" ; graphictextdirective "\documentclass[]{article}" ; beginfig (1) ; @@ -272,11 +280,11 @@ beginfig (1) ; withdrawcolor blue withfillcolor red withpen pencircle scaled 2pt ; -endfig ; +endfig ; -beginfig(1) ; - loadfigure "gracht.mp" rotated 20 ; - loadfigure "koe.mp" number 1 scaled 2 ; -endfig ; +beginfig(1) ; + loadfigure "gracht.mp" rotated 20 ; + loadfigure "koe.mp" number 1 scaled 2 ; +endfig ; end diff --git a/metapost/context/mp-spec.mp b/metapost/context/mp-spec.mp index dca7ffdbc..10118f2c0 100644 --- a/metapost/context/mp-spec.mp +++ b/metapost/context/mp-spec.mp @@ -261,11 +261,16 @@ enddef ; %D Since a \type {fill p withshade s} syntax looks better %D than some macro, we implement a new primary. -primarydef p withshade sc = +primarydef p withshade sc = % == p withcolor shadecolor(sh) hide (_color_counter_ := _color_counter_ + 1) p withcolor (_special_signal_/1000,_color_counter_/1000,sc/1000) enddef ; +vardef shadecolor(expr sc) = + hide (_color_counter_ := _color_counter_ + 1) + (_special_signal_/1000,_color_counter_/1000,sc/1000) +enddef ; + %D Figure inclusion. %numeric cef ; cef := 0 ; diff --git a/metapost/context/mp-tool.mp b/metapost/context/mp-tool.mp index 210c34632..b1fd6bf22 100644 --- a/metapost/context/mp-tool.mp +++ b/metapost/context/mp-tool.mp @@ -1999,7 +1999,7 @@ enddef ; def addbackground text t = begingroup ; save p ; picture p ; p := currentpicture ; currentpicture := nullpicture ; - fill boundingbox p t ; draw p ; + fill boundingbox p t ; addto currentpicture also p ; endgroup ; enddef ; @@ -2048,6 +2048,13 @@ vardef unstringed (expr s) = expandafter known scantokens(cleanstring(s)) enddef ; +% new + +vardef colorpart(expr i) = + (redpart i, greenpart i,bluepart i) +enddef ; + + % done endinput ; |