s-version.mkiv /size: 4905 b    last modification: 2021-10-28 13:51
1
%D \module
2
%D [ file=s-version,
3
%D version=2011.07.28,
4
%D title=\CONTEXT\ Version Pictogram,
5
%D subtitle=Basics,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
%D This is an oldie that we use to generate a pictogram that reflects the current
15
%D version.
16 17
\startMPextensions
18
vardef
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
:
=
360
/
7.25
;
delta
:
=
(
360
-7
*
angle
)
/
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
.7
white
;
42
fi
;
43 44
color
colorant
[
]
;
45 46
vardef
do_context_version
(
expr
i
,
amount
)
=
47
fill
(
min
/
2
rotated
(
-
angle
/
2
)
--
max
{
dir
-40
}
..
max
rotated
-
angle
--
cycle
)
rotated
-
(
i
*
(
angle
+
delta
)
)
withcolor
.3
colorant
[
i
]
;
48
fill
(
min
rotated
(
-
angle
/
2
)
--
max
{
dir
-
(
45
+45
*
amount
)
}
..
max
rotated
-
angle
--
cycle
)
rotated
-
(
i
*
(
angle
+
delta
)
)
withcolor
.7
colorant
[
i
]
;
49
enddef
;
50 51
color
orange
;
orange
:
=
(
1
,
.62
,
.06
)
;
% .5white
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
.3
white
;
69
setbounds
currentpicture
to
boundingbox
currentpicture
enlarged
-5
;
70
fi
;
71 72
)
73 74
enddef
;
75 76
% draw context_version(4,2011,07,28,14,50,30) ;
77
% draw context_version(4,01,01,01,01,01,01) ;
78
% draw context_version(4,99,12,31,24,60,60) ;
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
{
s
-
version
.
mkiv
}
110 111
\starttext
112 113
\startluacode
114
context
.
startTEXpage
(
)
115
moduledata
.
versions
.
drawcontextversion
(
)
116
context
.
stopTEXpage
(
)
117
\stopluacode
118 119
\stoptext
120 121
% d:\imagemagick\convert.exe -geometry 256x256 s-version.pdf context-version.png
122
% d:\imagemagick\convert.exe -geometry 72x72 s-version.pdf context-version.ico
123
% d:\imagemagick\convert.exe -geometry 128x128 s-version.pdf context-version.icns
124