1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17\startMPextensions
18vardef context_version(expr variant, mark, year, month, day, hours, minutes, seconds) =
19
20 image (
21
22 interim overloadmode := 0;
23
24 save angle, min, max, mk, yr, mo, da, ho, mi, se, max_mk, max_yr, max_mo, max_da, max_ho, max_mi, max_se ;
25
26 numeric angle, delta ; pair min, max ; angle := 3607.25 ; delta := (360-7angle)7 ; min := (0,10) ; max := (0,100) ;
27
28 numeric mk, max_mk ; max_mk := 8 ; mk := if (mark <= 0) or (mark > max_mk) : max_mk else : mark fi ;
29 numeric yr, max_yr ; max_yr := 2050 ; yr := if (year <= 2000) or (year > max_yr) : max_yr else : year fi ;
30 numeric mo, max_mo ; max_mo := 12 ; mo := if (month <= 0) or (month > max_mo) : max_mo else : month fi ;
31 numeric da, max_da ; max_da := 31 ; da := if (day <= 0) or (day > max_da) : max_da else : day fi ;
32 numeric ho, max_ho ; max_ho := 24 ; ho := if (hours <= 0) or (hours > max_ho) : max_ho else : hours fi ;
33 numeric mi, max_mi ; max_mi := 60 ; mi := if (minutes <= 0) or (minutes > max_mi) : max_mi else : minutes fi ;
34 numeric se, max_se ; max_se := 60 ; se := if (seconds <= 0) or (seconds > max_se) : max_se else : seconds fi ;
35
36 max_da := if (mo = 2) : 28 elseif (mo = 4) or (mo = 6) or (mo = 9) or (mo = 11) : 30 else : 31 fi ;
37
38 if da > max_da : da := max_da fi ; yr := yr 2000 ; max_yr := max_yr 2000 ;
39
40 if (variant = 2) or (variant = 3) :
41 fill fullcircle scaled 205 withcolor .7white ;
42 fi ;
43
44 color colorant[] ;
45
46 vardef do_context_version(expr i, amount) =
47 fill (min2 rotated (angle2) -- max { dir -40 } .. max rotated angle -- cycle) rotated (i(angledelta)) withcolor .3colorant[i] ;
48 fill (min rotated (angle2) -- max { dir (45+45amount) } .. max rotated angle -- cycle) rotated (i(angledelta)) withcolor .7colorant[i] ;
49 enddef ;
50
51 color orange ; orange := (1,.62,.06) ;
52
53 colorant[0] := red ; colorant[1] := green ; colorant[2] := blue ; colorant[3] := orange ;
54 colorant[4] := cyan ; colorant[5] := magenta ; colorant[6] := yellow ;
55
56 do_context_version(0, (yr-1)max_yr) ;
57 do_context_version(1, (mo-1)max_mo) ;
58 do_context_version(2, (da-1)max_da) ;
59 do_context_version(3, (mk-1)max_mk) ;
60 do_context_version(4, (ho-1)max_ho) ;
61 do_context_version(5, (mi-1)max_mi) ;
62 do_context_version(6, (se-1)max_se) ;
63
64 currentpicture := currentpicture slanted .15 ;
65
66 if (variant = 3) :
67 setbounds currentpicture to boundingbox currentpicture enlarged 10 ;
68 addbackground withcolor .3white ;
69 setbounds currentpicture to boundingbox currentpicture enlarged -5 ;
70 fi ;
71
72 )
73
74enddef ;
75
76
77
78
79
80\stopMPextensions
81
82\startluacode
83 moduledata.versions = moduledata.versions or { }
84
85 function moduledata.versions.drawcontextversion(variant, mark, year, month, day, hours, minutes, seconds)
86 if not variant then
87 variant = 3
88 end
89 if not mark then
90 mark = 4
91 year, month, day, hours, minutes, seconds = string.match(environment.version,"(....).(..).(..) (..).(..)")
92 seconds = 30
93 end
94 context.startMPcode()
95 context("draw context_version(%s,%s,%s,%s,%s,%s,%s,%s) ;",
96 variant or 1,
97 mark or 4,
98 year or os.date("%y"),
99 month or os.date("%m"),
100 day or os.date("%d"),
101 hours or os.date("%H"),
102 minutes or os.date("%M"),
103 seconds or os.date("%S")
104 )
105 context.stopMPcode()
106 end
107\stopluacode
108
109\continueifinputfile{sversion.mkiv}
110
111\starttext
112
113\startluacode
114 context.startTEXpage()
115 moduledata.versions.drawcontextversion()
116 context.stopTEXpage()
117\stopluacode
118
119\stoptext
120
121
122
123
124 |