summaryrefslogtreecommitdiff
path: root/metapost
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2015-06-12 10:15:04 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2015-06-12 10:15:04 +0200
commitc727ed7331960718681fa4222bec81fb577b56fb (patch)
treee90818d7ead83f08561f6c89396e1f5f1074b157 /metapost
parent3e816646efde05d34564646800299790d32a2607 (diff)
downloadcontext-c727ed7331960718681fa4222bec81fb577b56fb.tar.gz
2015-06-12 10:08:00
Diffstat (limited to 'metapost')
-rw-r--r--metapost/context/base/mp-cows.mpiv156
-rw-r--r--metapost/context/base/mp-grph.mpiv177
-rw-r--r--metapost/context/base/mp-mlib.mpiv146
-rw-r--r--metapost/context/base/mp-tool.mpiv34
4 files changed, 461 insertions, 52 deletions
diff --git a/metapost/context/base/mp-cows.mpiv b/metapost/context/base/mp-cows.mpiv
new file mode 100644
index 000000000..3ad1a98f5
--- /dev/null
+++ b/metapost/context/base/mp-cows.mpiv
@@ -0,0 +1,156 @@
+%D \module
+%D [ file=mp-cows.mpiv,
+%D version=2015.05.27,
+%D title=\CONTEXT\ \METAPOST\ graphics,
+%D subtitle=the cow,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%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.
+
+if known context_cows : endinput ; fi ;
+
+boolean context_cows ; context_cows := true ;
+
+picture cow ; cow := image (
+ fill (245.449005,600.340027)..controls (242.781006,599.398010) and (239.621002,596.020020)..(237.671997,594.070007)
+ ..controls (236.738007,584.421997) and (244.578003,583.629028)..(250.199005,577.440979)
+ ..controls (258.769989,573.698975) and (251.210999,567.718994)..(256.179993,557.421997)
+ ..controls (257.039001,550.940979) and (257.898010,543.890991)..(255.309006,539.781006)
+ ..controls (249.479996,538.921997) and (247.968994,540.218994)..(246.891006,531.429993)
+ ..controls (246.309006,526.968994) and (231.770004,529.059021)..(229.031006,538.270020)
+ ..controls (227.089996,544.968994) and (221.328003,546.698975)..(217.800995,543.171997)
+ ..controls (213.770004,538.059021) and (215.781006,531.218994)..(217.800995,527.468994)
+ ..controls (224.929993,517.320007) and (212.039001,511.421997)..(205.128998,516.737976)
+ ..controls (199.729996,508.679993) and (211.391006,500.039001)..(207.429993,494.500000)
+ ..controls (205.781006,493.988007) and (204.770004,489.171997)..(185.468994,500.539001)
+ ..controls (180.358994,504.140991) and (167.828003,500.761993)..(168.770004,520.629028)
+ ..controls (168.770004,525.820007) and (165.602005,543.531006)..(162.141006,555.909973)
+ ..controls (159.410004,561.237976) and (156.738007,559.078003)..(156.891006,553.898010)
+ ..controls (157.179993,547.851990) and (162.940994,531.218994)..(155.520004,540.218994)
+ ..controls (153.578003,539.210999) and (156.891006,523.578003)..(156.891006,521.640991)
+ ..controls (162.000000,517.031006) and (157.391006,513.578003)..(154.729996,512.281006)
+ ..controls (151.270004,518.328003) and (149.621002,518.039001)..(147.171997,514.440979)
+ ..controls (141.699005,514.078003) and (144.578003,528.190979)..(140.261993,528.620972)
+ ..controls (137.020004,527.762024) and (139.179993,520.059021)..(138.238007,518.762024)
+ ..controls (132.979996,524.737976) and (130.897995,529.270020)..(127.012001,521.640991)
+ ..controls (126.140999,521.640991) and (122.109001,519.190979)..(120.960999,526.539001)
+ ..controls (117.648003,552.737976) and (107.058998,558.359009)..(93.820297,565.129028)
+ ..controls (92.019501,565.629028) and (84.238297,566.710999)..(79.339798,568.148010)
+ ..controls (73.511703,560.879028) and (58.320301,565.629028)..(56.230499,570.309021)
+ ..controls (54.789101,572.690979) and (54.648399,575.210999)..(54.789101,576.500000)
+ ..controls (52.339802,580.101990) and (55.871101,582.698975)..(59.621101,583.059021)
+ ..controls (62.859402,587.159973) and (68.539101,594.940979)..(71.281303,601.559021)
+ ..controls (72.289101,603.070007) and (74.949203,609.340027)..(78.191399,609.551025)
+ ..controls (74.949203,612.940979) and (74.300797,622.512024)..(82.660202,617.328003)
+ ..controls (87.121101,624.020020) and (92.089798,624.309021)..(95.761703,615.820007)
+ ..controls (102.890999,615.379028) and (102.308998,608.690979)..(115.780998,605.520020)
+ ..controls (122.762001,602.859009) and (132.770004,604.578003)..(140.261993,603.718994)
+ ..controls (136.218994,596.879028) and (127.441002,566.859009)..(132.979996,559.801025)
+ ..controls (140.761993,564.698975) and (141.839996,605.379028)..(157.031006,595.659973)
+ ..controls (160.559006,593.929993) and (159.910004,590.039001)..(164.089996,590.179993)
+ ..controls (170.421997,587.448975) and (169.128998,600.770020)..(172.511993,600.770020)
+ ..controls (176.468994,599.762024) and (183.020004,599.039001)..(186.979996,599.539001)
+ ..controls (197.710999,600.770020) and (206.929993,604.078003)..(223.921997,602.500000)
+ ..controls (231.121002,601.781006) and (238.250000,601.059021)..(245.449005,600.340027)
+ --cycle;
+ fill (305.281006,560.948975)..controls (304.628998,560.948975) and (299.949005,561.237976)..(299.378998,561.237976)
+ ..controls (302.398010,550.440979) and (303.980011,536.468994)..(304.199005,525.309021)
+ ..controls (303.699005,521.351990) and (299.808990,517.460999)..(299.378998,525.671997)
+ ..controls (295.851990,530.859009) and (296.421997,540.070007)..(293.398010,540.289001)
+ ..controls (287.351990,539.640991) and (285.339996,513.218994)..(280.011993,509.328003)
+ ..controls (276.261993,512.281006) and (280.730011,524.020020)..(275.539001,524.737976)
+ ..controls (270.500000,524.020020) and (264.308990,526.679993)..(266.691010,534.460999)
+ ..controls (270.289001,543.020020) and (268.339996,554.762024)..(266.539001,561.601990)
+ ..controls (262.371002,578.590027) and (264.019989,587.090027)..(271.578003,596.090027)
+ --(267.480011,604.512024)..controls (275.398010,608.262024) and (285.621002,604.578003)..(290.019989,602.210999)
+ ..controls (294.621002,600.262024) and (300.238007,595.940979)..(301.101990,587.379028)
+ ..controls (303.339996,578.879028) and (304.421997,569.737976)..(305.281006,560.948975)
+ --cycle;
+ pickup pencircle scaled 2.000000bp;
+ draw (84.378899,618.551025)..controls (88.339798,624.379028) and (92.589798,622.940979)..(96.339798,615.671997)
+ ..controls (101.230003,615.601990) and (102.460999,612.429993)..(104.980003,610.781006)
+ ..controls (122.621002,598.390991) and (147.460999,607.179993)..(167.897995,601.921997)
+ ..controls (180.940994,598.539001) and (190.871002,599.762024)..(200.089996,602.059021)
+ ..controls (220.320007,607.250000) and (246.102005,596.159973)..(263.738007,603.859009)
+ ..controls (274.750000,608.620972) and (284.761993,605.659973)..(292.968994,600.909973)
+ ..controls (297.578003,597.960999) and (299.589996,596.090027)..(300.960999,591.262024)
+ ..controls (306.289001,572.539001) and (306.289001,551.020020)..(309.531006,530.570007)
+ ..controls (309.531006,528.840027) and (312.191010,526.101990)..(312.480011,522.070007)
+ ..controls (315.789001,511.339996) and (316.078003,510.121002)..(317.160004,502.199005)
+ ..controls (317.160004,501.339996) and (326.519989,488.449005)..(325.011993,479.019989)
+ ..controls (323.929993,481.250000) and (323.859009,482.828003)..(321.621002,481.679993)
+ ..controls (320.328003,479.300995) and (320.898010,473.898010)..(322.558990,471.738007)
+ ..controls (320.828003,470.808990) and (318.460999,473.468994)..(317.519989,475.199005)
+ ..controls (318.171997,473.039001) and (317.808990,470.808990)..(316.730011,469.300995)
+ ..controls (315.859009,472.250000) and (316.578003,473.179993)..(315.359009,473.898010)
+ ..controls (313.988007,472.898010) and (314.210999,469.300995)..(314.281006,466.199005)
+ ..controls (313.488007,468.070007) and (311.468994,472.460999)..(312.550995,476.421997)
+ ..controls (312.480011,484.199005) and (308.808990,489.101990)..(310.320007,499.101990)
+ ..controls (310.101990,504.429993) and (307.300995,521.059021)..(304.558990,524.301025)
+ ..controls (303.121002,526.250000) and (306.359009,510.769989)..(306.359009,506.160004)
+ ..controls (306.648010,500.898010) and (307.078003,468.718994)..(306.429993,463.101990)
+ ..controls (306.429993,459.218994) and (306.218994,453.960999)..(307.078003,452.160004)
+ ..controls (308.738007,450.789001) and (309.378998,450.500000)..(309.601990,447.980011)
+ ..controls (309.238007,446.621002) and (308.738007,446.039001)..(307.730011,445.539001)
+ ..controls (306.070007,444.601990) and (307.371002,441.789001)..(306.070007,439.851990)
+ ..controls (304.488007,438.769989) and (304.128998,441.859009)..(303.339996,441.859009)
+ ..controls (302.691010,441.000000) and (303.050995,437.980011)..(302.468994,436.179993)
+ ..controls (299.660004,433.800995) and (292.179993,432.500000)..(289.148010,434.660004)
+ ..controls (289.730011,440.640991) and (291.738007,441.578003)..(295.628998,446.621002)
+ ..controls (298.660004,452.589996) and (297.000000,460.941010)..(296.929993,468.140991)
+ ..controls (295.488007,480.378998) and (289.218994,487.300995)..(289.441010,496.441010)
+ ..controls (287.859009,495.718994) and (286.421997,494.570007)..(284.261993,494.859009)
+ ..controls (283.390991,489.460999) and (286.421997,484.558990)..(284.828003,480.820007)
+ ..controls (281.949005,471.960999) and (277.058990,446.621002)..(279.000000,437.761993)
+ ..controls (280.011993,434.738007) and (278.210999,433.148010)..(277.058990,433.941010)
+ ..controls (276.769989,433.941010) and (276.550995,433.941010)..(276.410004,433.941010)
+ ..controls (276.410004,433.941010) and (276.550995,431.421997)..(275.691010,430.921997)
+ ..controls (274.101990,430.339996) and (273.671997,431.710999)..(272.660004,432.140991)
+ ..controls (271.218994,430.851990) and (272.519989,429.480011)..(271.148010,428.039001)
+ ..controls (267.191010,428.039001) and (261.359009,425.378998)..(257.980011,428.261993)
+ ..controls (257.328003,434.160004) and (263.300995,436.679993)..(266.468994,440.710999)
+ ..controls (268.628998,446.621002) and (271.078003,462.890991)..(267.769989,474.621002)
+ ..controls (267.769989,475.558990) and (264.378998,485.281006)..(261.429993,488.660004)
+ ..controls (258.699005,487.660004) and (257.328003,485.500000)..(253.218994,486.289001)
+ ..controls (252.578003,484.339996) and (253.300995,482.328003)..(252.218994,480.101990)
+ ..controls (251.858994,479.519989) and (249.339996,478.578003)..(249.190994,481.390991)
+ ..controls (248.979996,483.050995) and (248.897995,486.359009)..(248.261993,486.718994)
+ ..controls (243.647995,486.718994) and (233.710999,487.078003)..(231.770004,493.921997)
+ ..controls (219.891006,492.339996) and (215.929993,491.261993)..(206.570007,493.421997)
+ ..controls (196.628998,489.671997) and (183.238007,506.160004)..(174.531006,502.199005)
+ ..controls (172.511993,496.148010) and (173.089996,485.640991)..(171.647995,481.390991)
+ ..controls (169.339996,474.769989) and (171.141006,467.140991)..(171.141006,456.410004)
+ ..controls (170.570007,455.398010) and (169.852005,454.460999)..(168.479996,454.460999)
+ ..controls (168.479996,453.101990) and (169.339996,450.859009)..(168.621002,449.421997)
+ ..controls (167.179993,447.621002) and (165.891006,451.800995)..(165.020004,444.601990)
+ ..controls (163.147995,443.738007) and (157.750000,442.218994)..(155.589996,445.179993)
+ ..controls (155.878998,448.988007) and (158.328003,451.300995)..(160.128998,453.378998)
+ ..controls (161.421997,456.910004) and (160.988007,458.281006)..(160.699005,461.808990)
+ ..controls (160.988007,464.980011) and (161.710999,468.578003)..(161.858994,470.089996)
+ ..controls (161.858994,473.039001) and (162.500000,479.300995)..(161.141006,481.179993)
+ --(159.410004,482.691010)..controls (157.179993,487.218994) and (158.328003,494.640991)..(157.608994,500.261993)
+ ..controls (155.809006,500.691010) and (155.809006,500.980011)..(154.011993,498.308990)
+ ..controls (154.011993,494.421997) and (153.500000,486.359009)..(152.352005,483.839996)
+ ..controls (149.690994,479.808990) and (150.839996,459.648010)..(151.421997,448.558990)
+ ..controls (151.781006,446.468994) and (149.690994,447.699005)..(149.761993,444.738007)
+ ..controls (150.050995,442.800995) and (147.891006,443.589996)..(146.089996,444.601990)
+ ..controls (145.147995,445.179993) and (146.589996,439.781006)..(145.371002,439.558990)
+ ..controls (142.339996,438.839996) and (136.871002,438.191010)..(135.218994,440.710999)
+ ..controls (134.570007,444.601990) and (137.878998,448.058990)..(140.621002,451.011993)
+ ..controls (143.141006,455.828003) and (140.897995,465.699005)..(140.468994,476.281006)
+ --(138.891006,478.218994)..controls (134.858994,483.191010) and (139.608994,496.941010)..(136.511993,506.230011)
+ ..controls (120.019997,514.870972) and (122.109001,519.190979)..(118.730003,537.620972)
+ ..controls (115.128998,557.640991) and (93.378899,567.648010)..(79.058601,567.648010)
+ ..controls (73.441399,563.039001) and (66.238297,563.620972)..(58.539101,567.648010)
+ ..controls (55.660198,569.229980) and (54.429699,573.190979)..(54.500000,576.500000)
+ ..controls (52.628899,580.750000) and (55.218800,582.190979)..(59.621101,583.487976)
+ ..controls (62.710899,587.809021) and (68.621101,594.648010)..(69.191399,597.737976)
+ ..controls (70.339798,601.921997) and (75.531303,608.109009)..(77.761703,609.770020)
+ ..controls (75.820297,613.012024) and (74.808601,615.171997)..(77.109398,618.551025)
+ ..controls (79.558601,620.140991) and (81.789101,616.609009)..(84.378899,618.551025)
+ --cycle;
+) ;
diff --git a/metapost/context/base/mp-grph.mpiv b/metapost/context/base/mp-grph.mpiv
index a3c057a98..5938b9f02 100644
--- a/metapost/context/base/mp-grph.mpiv
+++ b/metapost/context/base/mp-grph.mpiv
@@ -118,7 +118,18 @@ def doloadfigure (expr filename) text figureattributes =
endgroup ;
enddef ;
-def graphictext primary t =
+% shared between old and new
+
+boolean mfun_gt_color_fill ;
+boolean mfun_gt_color_draw ;
+boolean mfun_gt_shade_fill ;
+boolean mfun_gt_reverse_fill ;
+boolean mfun_gt_outline_fill ;
+picture mfun_gt_picture ;
+
+% this is the old version:
+
+def old_graphictext primary t =
hide (
if mfun_trial_run :
let mfun_graphic_text = mfun_no_graphic_text ;
@@ -146,7 +157,7 @@ def mfun_no_graphic_text (expr t) text rest =
withpostscript t
enddef ;
-def mfun_finish_graphic_text text x_op_x =
+def mfun_finish_graphic_text text rest =
protectgraphicmacros ; % resets currentpicture
interim linecap := butt ; % normally rounded
interim linejoin := mitered ; % normally rounded
@@ -166,84 +177,158 @@ def mfun_finish_graphic_text text x_op_x =
def fill expr p =
addto scratchpicture contour p withpen currentpen ;
enddef ;
- def f_op_f = enddef ; boolean f_color ; f_color := false ;
- def d_op_d = enddef ; boolean d_color ; d_color := false ;
- def s_op_s = enddef ; boolean s_color ; s_color := false ;
- boolean reverse_fill ; reverse_fill := false ;
- boolean outline_fill ; outline_fill := false ;
+ def mfun_gt_fill = enddef ; boolean mfun_gt_color_fill ; mfun_gt_color_fill := false ;
+ def mfun_gt_draw = enddef ; boolean mfun_gt_color_draw ; mfun_gt_color_draw := false ;
+ def mfun_gt_shade = enddef ; boolean mfun_gt_shade_fill ; mfun_gt_shade_fill := false ;
+ boolean mfun_gt_reverse_fill ; mfun_gt_reverse_fill := false ;
+ boolean mfun_gt_outline_fill ; mfun_gt_outline_fill := false ;
def reversefill =
- hide(reverse_fill := true )
+ hide(mfun_gt_reverse_fill := true )
enddef ;
def outlinefill =
- hide(outline_fill := true )
+ hide(mfun_gt_outline_fill := true )
enddef ;
def withshade primary c =
- hide(def s_op_s = normalwithshade c enddef ; s_color := true )
+ hide(def mfun_gt_shade = normalwithshade c enddef ; mfun_gt_shade_fill := true )
enddef ;
def withfillcolor primary c =
- hide(def f_op_f = withcolor c enddef ; f_color := true )
+ hide(def mfun_gt_fill = withcolor c enddef ; mfun_gt_color_fill := true )
enddef ;
def withdrawcolor primary c =
- hide(def d_op_d = withcolor c enddef ; d_color := true )
+ hide(def mfun_gt_draw = withcolor c enddef ; mfun_gt_color_draw := true )
enddef ;
scratchpicture := nullpicture ;
- addto scratchpicture doublepath origin x_op_x ; % pre-roll
+ addto scratchpicture doublepath origin rest ; % pre-roll
for i within scratchpicture : % Below here is a dirty tricky test!
if (urcorner dashpart i) = origin :
- outline_fill := false ;
+ mfun_gt_outline_fill := false ;
fi ;
endfor ;
scratchpicture := nullpicture ;
readfile(data_mpy_file) ;
scratchpicture := (scratchpicture shifted -llcorner scratchpicture) scaled (1/10) ;
- if not d_color and not f_color :
- d_color := true ;
+ if not mfun_gt_color_draw and not mfun_gt_color_fill :
+ mfun_gt_color_draw := true ;
fi
- if s_color :
- d_color := false ;
- f_color := false ;
+ if mfun_gt_shade_fill :
+ mfun_gt_color_draw := false ;
+ mfun_gt_color_fill := false ;
fi ;
currentpicture := figurepicture ;
- if d_color and not reverse_fill :
+ if mfun_gt_shade_fill :
for i within scratchpicture :
- if f_color and outline_fill :
- addto currentpicture doublepath pathpart i _op_ x_op_x f_op_f dashed nullpicture ;
- fi ;
if filled i :
- addto currentpicture doublepath pathpart i _op_ x_op_x d_op_d ;
- fi ;
- endfor ;
- fi ;
- if f_color :
- for i within scratchpicture :
- if filled i :
- addto currentpicture contour pathpart i _op_ x_op_x f_op_f withpen pencircle scaled 0 ;
- fi ;
- endfor ;
- fi ;
- if d_color and reverse_fill :
- for i within scratchpicture :
- if filled i :
- addto currentpicture doublepath pathpart i _op_ x_op_x d_op_d ;
- fi ;
- endfor ;
- fi ;
- if s_color :
- for i within scratchpicture :
- if filled i :
- addto currentpicture contour pathpart i _op_ x_op_x s_op_s ;
+ addto currentpicture contour pathpart i _op_ rest mfun_gt_shade ;
fi ;
endfor ;
else :
+ if mfun_gt_color_draw and not mfun_gt_reverse_fill :
+ for i within scratchpicture :
+ if mfun_gt_color_fill and mfun_gt_outline_fill :
+ addto currentpicture doublepath pathpart i _op_ rest mfun_gt_fill dashed nullpicture ;
+ fi ;
+ if filled i :
+ addto currentpicture doublepath pathpart i _op_ rest mfun_gt_draw ;
+ fi ;
+ endfor ;
+ fi ;
+ if mfun_gt_color_fill :
+ for i within scratchpicture :
+ if filled i :
+ addto currentpicture contour pathpart i _op_ rest mfun_gt_fill withpen pencircle scaled 0 ;
+ fi ;
+ endfor ;
+ fi ;
+ if mfun_gt_color_draw and mfun_gt_reverse_fill :
+ for i within scratchpicture :
+ if filled i :
+ addto currentpicture doublepath pathpart i _op_ rest mfun_gt_draw ;
+ fi ;
+ endfor ;
+ fi ;
for i within scratchpicture :
if stroked i :
- addto currentpicture doublepath pathpart i _op_ x_op_x d_op_d ;
+ addto currentpicture doublepath pathpart i _op_ rest mfun_gt_draw ;
fi ;
endfor ;
fi ;
endgroup ;
enddef ;
+% and this is the new one:
+
+% boolean mfun_gt_color_fill ;
+% boolean mfun_gt_color_draw ;
+% boolean mfun_gt_shade_fill ;
+% boolean mfun_gt_reverse_fill ;
+% picture mfun_gt_picture ;
+
+def mfun_gt_default = % somewhat compatible
+ scaled 11.5
+ withpen pencircle scaled .1
+enddef ;
+
+def new_graphictext primary t = % use outlinetext instead
+ begingroup ;
+ mfun_graphic_text_indeed(t)
+enddef ;
+
+def mfun_graphic_text_indeed(expr t) text rest =
+ interim linecap := butt ; % normally rounded
+ interim linejoin := mitered ; % normally rounded
+ % interim miterlimit := 10 ; % todo
+ %
+ let normalwithshade = withshade ;
+ %
+ save reversefill, outlinefill, withshade, withfillcolor, withdrawcolor ;
+ %
+ def mfun_gt_fill = enddef ;
+ def mfun_gt_draw = enddef ;
+ def mfun_gt_shade = enddef ;
+ %
+ mfun_gt_color_fill := false ;
+ mfun_gt_color_draw := false ;
+ mfun_gt_shade_fill := false ;
+ mfun_gt_reverse_fill := false ;
+ %
+ def reversefill = hide(mfun_gt_reverse_fill := true) enddef ;
+ def outlinefill = enddef ;
+ def withshade primary c = hide(mfun_gt_shade_fill := true; def mfun_gt_shade = normalwithshade c enddef ;) enddef ;
+ def withfillcolor primary c = hide(mfun_gt_color_fill := true; def mfun_gt_fill = withcolor c enddef ;) enddef ;
+ def withdrawcolor primary c = hide(mfun_gt_color_draw := true; def mfun_gt_draw = withcolor c enddef ;) enddef ;
+ %
+ mfun_gt_picture := nullpicture ;
+ addto mfun_gt_picture doublepath origin rest ; % preroll
+ mfun_gt_picture := nullpicture ;
+ %
+ def reversefill = enddef ;
+ def outlinefill = enddef ;
+ def withshade primary c = enddef ;
+ def withfillcolor primary c = enddef ;
+ def withdrawcolor primary c = enddef ;
+ %
+ if mfun_gt_shade_fill :
+ draw outlinetext.f(t)(mfun_gt_shade) rest;
+ elseif mfun_gt_color_fill and mfun_gt_color_draw :
+ if mfun_gt_reverse_fill :
+ draw outlinetext.r(t)(mfun_gt_default mfun_gt_fill rest)(mfun_gt_default mfun_gt_draw rest) ;
+ else :
+ draw outlinetext.b(t)(mfun_gt_default mfun_gt_draw rest)(mfun_gt_default mfun_gt_fill rest);
+ fi ;
+ elseif mfun_gt_color_fill :
+ draw outlinetext.f(t)(mfun_gt_default mfun_gt_fill rest) ;
+ elseif mfun_gt_color_draw :
+ draw outlinetext.d(t)(mfun_gt_default mfun_gt_draw rest) ;
+ else :
+ draw outlinetext.d(t)(mfun_gt_default rest) ;
+ fi ;
+ %
+ endgroup ;
+enddef ;
+
+let graphictext = old_graphictext ;
+%%% graphictext = new_graphictext ; % more than 10 times faster
+
% example
%
% beginfig (1) ;
diff --git a/metapost/context/base/mp-mlib.mpiv b/metapost/context/base/mp-mlib.mpiv
index b19f47f1e..6d4894fb6 100644
--- a/metapost/context/base/mp-mlib.mpiv
+++ b/metapost/context/base/mp-mlib.mpiv
@@ -467,6 +467,15 @@ boolean trace_shades ; trace_shades := false ; % still there
% but this is nicer
+% fill fullcircle scaled 10cm
+% withshademethod "circular"
+% withshadevector (5cm,1cm)
+% withshadecenter (.1,.5)
+% withshadedomain (.2,.6)
+% withshadefactor 1.2
+% withshadecolors (red,green)
+% ;
+
path mfun_shade_path ;
primarydef p withshademethod m =
@@ -746,9 +755,145 @@ def register (expr tag, width, height, offset) =
% ) ; % no transformations
enddef ;
+% outlines (todo: pass around less arguments)
+
+numeric currentoutlinetext ; currentoutlinetext := 0 ;
+
+vardef mfun_do_outline_text_flush (expr kind, n, x, y) (text t) =
+ if kind = "f" :
+ mfun_do_outline_text_f (n, x, y) (t)
+ elseif kind = "d" :
+ mfun_do_outline_text_d (n, x, y) (t)
+ elseif kind = "b" :
+ mfun_do_outline_text_b (n, x, y) (t)
+ elseif kind = "r" :
+ mfun_do_outline_text_r (n, x, y) (t)
+ else :
+ mfun_do_outline_text_n (n, x, y) (t)
+ fi ;
+enddef ;
+
+numeric mfun_do_outline_n ; mfun_do_outline_n := 0 ;
+
+vardef mfun_do_outline_text_f (expr n, x, y) (text t) =
+ mfun_do_outline_n := 0 ;
+ for i=t :
+ mfun_do_outline_n := mfun_do_outline_n + 1 ;
+ if mfun_do_outline_n = n :
+ fill i shifted(x,y) mfun_do_outline_options_f
+ else :
+ nofill i shifted(x,y)
+ fi ;
+ endfor ;
+enddef ;
+
+vardef mfun_do_outline_text_d (expr n, x, y) (text t) =
+ for i=t :
+ draw i shifted(x,y) mfun_do_outline_options_d ;
+ endfor ;
+enddef ;
+
+vardef mfun_do_outline_text_b (expr n, x, y) (text t) =
+ mfun_do_outline_n := 0 ;
+ for i=t :
+ mfun_do_outline_n := mfun_do_outline_n + 1 ;
+ if mfun_do_outline_n = n :
+ fill i shifted(x,y) mfun_do_outline_options_f
+ else :
+ nofill i shifted(x,y)
+ fi ;
+ endfor ;
+ for i=t :
+ draw i shifted(x,y) mfun_do_outline_options_d ;
+ endfor ;
+enddef ;
+
+vardef mfun_do_outline_text_r (expr n, x, y) (text t) =
+ mfun_do_outline_n := 0 ;
+ for i=t :
+ draw i shifted(x,y) mfun_do_outline_options_d ;
+ endfor ;
+ for i=t :
+ mfun_do_outline_n := mfun_do_outline_n + 1 ;
+ if mfun_do_outline_n = n :
+ fill i shifted(x,y) mfun_do_outline_options_f
+ else :
+ nofill i shifted(x,y)
+ fi ;
+ endfor ;
+enddef ;
+
+vardef mfun_do_outline_text_n (expr n, x, y) (text t) =
+ mfun_do_outline_n := 0 ;
+ for i=t :
+ mfun_do_outline_n := mfun_do_outline_n + 1 ;
+ if mfun_do_outline_n = n : fill else : nofill fi i shifted(x,y) ;
+ endfor ;
+enddef ;
+
+vardef mfun_do_outline_text_set_f (text f) text r =
+ def mfun_do_outline_options_f = f enddef ;
+ def mfun_do_outline_options_r = r enddef ;
+enddef ;
+
+vardef mfun_do_outline_text_set_d (text d) text r =
+ def mfun_do_outline_options_d = d enddef ;
+ def mfun_do_outline_options_r = r enddef ;
+enddef ;
+
+vardef mfun_do_outline_text_set_b (text f) (text d) text r =
+ def mfun_do_outline_options_f = f enddef ;
+ def mfun_do_outline_options_d = d enddef ;
+ def mfun_do_outline_options_r = r enddef ;
+enddef ;
+
+vardef mfun_do_outline_text_set_r (text d) (text f) text r =
+ def mfun_do_outline_options_d = d enddef ;
+ def mfun_do_outline_options_f = f enddef ;
+ def mfun_do_outline_options_r = r enddef ;
+enddef ;
+
+vardef mfun_do_outline_text_set_n text r =
+ def mfun_do_outline_options_r = r enddef ;
+enddef ;
+
+def mfun_do_outline_options_d = enddef ;
+def mfun_do_outline_options_f = enddef ;
+def mfun_do_outline_options_r = enddef ;
+
+vardef outlinetext@# (expr t) text rest =
+ save kind ; string kind ; kind := str @# ;
+ currentoutlinetext := currentoutlinetext + 1 ;
+ image ( draw image (
+ if mfun_trial_run :
+ % lua.mp.report("set outline text",currentoutlinetext);
+ draw unitsquare
+ withprescript "ot_stage=trial"
+ withprescript "ot_index=" & decimal currentoutlinetext
+ withprescript "ot_kind=" & kind
+ withpostscript t ;
+ else :
+ % lua.mp.report("get outline text",currentoutlinetext);
+ if kind = "f" :
+ mfun_do_outline_text_set_f rest ;
+ elseif kind = "d" :
+ mfun_do_outline_text_set_d rest ;
+ elseif kind = "b" :
+ mfun_do_outline_text_set_b rest ;
+ elseif kind = "r" :
+ mfun_do_outline_text_set_r rest ;
+ else :
+ mfun_do_outline_text_set_n rest ;
+ fi ;
+ lua.mp.get_outline_text(currentoutlinetext) ;
+ fi ;
+ ) mfun_do_outline_options_r ; )
+enddef ;
+
% Housekeeping
extra_beginfig := extra_beginfig & "currentgraphictext := 0 ; " ;
+extra_beginfig := extra_beginfig & "currentoutlinetext := 0 ; " ;
extra_endfig := extra_endfig & "finishsavingdata ; " ;
extra_endfig := extra_endfig & "mfun_reset_tex_texts ; " ;
@@ -1206,6 +1351,7 @@ vardef formatted(expr f, x) = textext(varfmt(f, x)) enddef ;
% new
def eofill text t = fill t withpostscript "evenodd" enddef ;
+def nofill text t = fill t withpostscript "collect" enddef ;
%%% eoclip text t = clip t withpostscript "evenodd" enddef ; % no postscripts yet
% def withrule expr r =
diff --git a/metapost/context/base/mp-tool.mpiv b/metapost/context/base/mp-tool.mpiv
index e497e2f72..341a0a41a 100644
--- a/metapost/context/base/mp-tool.mpiv
+++ b/metapost/context/base/mp-tool.mpiv
@@ -1074,14 +1074,16 @@ def draworiginoptions (text t) = def _ori_opt_ = t enddef ; enddef ;
def drawboundoptions (text t) = def _bnd_opt_ = t enddef ; enddef ;
def drawpathoptions (text t) = def _pth_opt_ = t enddef ; enddef ;
+numeric drawoptionsfactor ; drawoptionsfactor := pt ;
+
def resetdrawoptions =
- drawlineoptions (withpen pencircle scaled 1pt withcolor .5white) ;
- drawpointoptions (withpen pencircle scaled 4pt withcolor black) ;
- drawcontroloptions(withpen pencircle scaled 2.5pt withcolor black) ;
+ drawlineoptions (withpen pencircle scaled 1drawoptionsfactor withcolor .5white) ;
+ drawpointoptions (withpen pencircle scaled 4drawoptionsfactor withcolor black) ;
+ drawcontroloptions(withpen pencircle scaled 2.5drawoptionsfactor withcolor black) ;
drawlabeloptions () ;
- draworiginoptions (withpen pencircle scaled 1pt withcolor .5white) ;
+ draworiginoptions (withpen pencircle scaled 1drawoptionsfactor withcolor .5white) ;
drawboundoptions (dashed evenly _ori_opt_) ;
- drawpathoptions (withpen pencircle scaled 5pt withcolor .8white) ;
+ drawpathoptions (withpen pencircle scaled 5drawoptionsfactor withcolor .8white) ;
enddef ;
resetdrawoptions ;
@@ -1152,13 +1154,25 @@ def mfun_draw_controllines text t =
enddef;
boolean swappointlabels ; swappointlabels := false ;
+numeric pointlabelscale ; pointlabelscale := 0 ;
+string pointlabelfont ; pointlabelfont := "" ;
def mfun_draw_pointlabels text t =
for _i_=0 upto length(_c_) :
pair _u_ ; _u_ := unitvector(direction _i_ of _c_) rotated if swappointlabels : - fi 90 ;
pair _p_ ; _p_ := (point _i_ of _c_) ;
- _u_ := 12 * defaultscale * _u_ ;
+ begingroup ;
+ if pointlabelscale > 0 :
+ save defaultscale ; numeric defaultscale ;
+ defaultscale := pointlabelscale ;
+ fi ;
+ if pointlabelfont <> "" :
+ save defaultfont ; string defaultfont ;
+ defaultfont := pointlabelfont ;
+ fi ;
+ _u_ := 10 * drawoptionsfactor * defaultscale * _u_ ;
normaldraw thelabel ( decimal _i_, _p_ shifted if cycle _c_ and (_i_=0) : - fi _u_ ) _lab_opt_ t ;
+ endgroup ;
endfor ;
enddef;
@@ -1233,6 +1247,14 @@ def drawwholepath expr p =
drawpointlabels p ;
enddef ;
+def drawpathonly expr p =
+ drawpath p ;
+ drawcontrollines p ;
+ drawcontrolpoints p ;
+ drawpoints p ;
+ drawpointlabels p ;
+enddef ;
+
%D Tracing.
def visualizeddraw expr c =