summaryrefslogtreecommitdiff
path: root/macros/context/contrib/context-pocketdiary/tex/context/third/pocketdiary/Solar/sun-MP.nkiv
blob: 0ccd8923cc85c5143c72f99427c4eed18c460674 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
%D \module
%D   [     file=t-pocketdiary,
%D      version=2023-04-15,
%D        title=PocketDiary \CONTEXT\ User Module,
%D     subtitle=Sun pictogrammes,
%D       author=Willi Egger,
%D         date=\currentdate,
%D    copyright=Willi Egger,
%D        email=w.egger@boede.nl,
%D      license=Public Domain]

% \setupbodyfont[plex,ss,14pt]

\defineMPinstance
	[Sun]
	[metafun]
  []
	
\startMPinclusions[]{Sun}
	numeric w,h;
	path p[];
	pair ip[];
	
	w = OverlayWidth;
	h = OverlayHeight;
	
	p[1]  := fullcircle scaled h;
	p[100] := tcircle scaled 0.5h; %h
	p[2] := tcircle scaled 0.6h;  %1.2h;
	p[3] := tcircle scaled 0.75h; %1.6h;
	p[4] := tcircle scaled h; %2h;
	p[5] := (0,0)--point 1 of p[4] ;
	p[6] := p[5] cutbefore point .3 of p[5];
	p[7] := p[6] rotatedaround (center p[1],18);
	 
  ip[1] :=  p[2] intersectionpoint p[7];
  ip[2] :=  p[3] intersectionpoint p[7];
	
  p[10] := ip[1]--ip[2];

	ip[3] :=  ip[1];
	ip[4] :=  point 1 of p[7];

	p[11] := ip[3]--ip[4];
	
  drawoptions (withpen pencircle scaled 0.25pt withcolor red);
	
\stopMPinclusions

\startreusableMPgraphic{Sun::Sunrise}
  drawoptions (withpen pencircle scaled 0.25pt withcolor red);
  draw p[100];
	for i = 36 step 36 until 154  :
	  draw p[10] rotatedaround (center p[1],i-18);
	endfor;
	for i = 18 step 36 until 180  :
	  draw p[11] rotatedaround (center p[1],i-18);
 endfor;
 drawarrow ((0,0)--(0,h)) shifted (0,-0.05h);
\stopreusableMPgraphic

\startreusableMPgraphic{Sun::Sunset}
  drawoptions (withpen pencircle scaled 0.25pt withcolor red);
  draw p[100];
	for i = 36 step 36 until 154  :
	  draw p[10] rotatedaround (center p[1],i-18);
	endfor;
	for i = 18 step 36 until 180  :
	  draw p[11] rotatedaround (center p[1],i-18);
 endfor;
 drawarrow ((0,h)--(0,0)) shifted (0,-0.05h) xscaled 0.5;
\stopreusableMPgraphic

\startreusableMPgraphic{Sun::Light}
  h := OverlayHeight;
	w := OverlayWidth;
  drawoptions (withpen pencircle scaled 0.15pt withcolor red);
	
	p[11] := ip[3]--ip[4];
	p[1]  := fullcircle scaled 0.25h;
	p[2] := tcircle scaled 0.35h;
	p[3] := tcircle scaled 0.5h;
	p[4] := tcircle scaled 0.8h;
	p[5] := (0,0)--point 1 of p[4] ;
	p[6] := p[5] cutbefore point .3 of p[5];
	p[7] := p[6] rotatedaround (center p[1],18);
	 
  ip[1] :=  p[2] intersectionpoint p[7];
  ip[2] :=  p[3] intersectionpoint p[7];
	
  p[10] := ip[1]--ip[2];

	ip[3] :=  ip[1];
	ip[4] :=  point 1 of p[7];

	p[11] := ip[3]--ip[4];

  draw p[1];
	for i = 36 step 36 until 360  :
	  draw p[10] rotatedaround (center p[1],i-18);
	endfor;
	for i = 18 step 36 until 360  :
	  draw p[11] rotatedaround (center p[1],i-18);
 endfor;
 
 currentpicture := currentpicture rotatedaround(center p[1],18);
\stopreusableMPgraphic

\defineoverlay[Sunrise][\useMPgraphic{Sun::Sunrise}]
\defineoverlay[Sunset][\useMPgraphic{Sun::Sunset}]
\defineoverlay[Light][\useMPgraphic{Sun::Light}]

\defineframed
	[SunA]
	[strut=yes,
	 height=\lineheight,
	 width=\emwidth,
 	 frame=off,
   offset=0pt]

\defineframed
	[SunB]
	[strut=yes,
	 height=\lineheight,
	 width=\emwidth,
 	 frame=off,
   offset=0pt,
	 location=depth]	 	
	
% \starttext
% \setupbodyfont[8pt] % This is the minimal size which looks still ok.
%
%  Sunrise:	{\SunA[background=Sunrise]{\strut}}
%  Sunset: \SunA[background=Sunset]{\strut}
%  Light hours: \SunB[background=Light]{\strut} Sunshine
%
% \stoptext