-
Notifications
You must be signed in to change notification settings - Fork 2
/
edt.typ
135 lines (124 loc) · 3.45 KB
/
edt.typ
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
#import "typtyp.typ"
#let tt = typtyp
#import "mpri.typ"
#import "time.typ"
#import "classes.typ"
#let blank_color = rgb("f8f8f8")
#let table_ratio = 94%
#let title_ratio = 5%
#let small_gutter = 1.5pt
#let large_gutter = 3pt
#let cell = rect.with(
inset: 10pt,
outset: 0pt,
width: 100%,
height: 100%,
radius: 6pt
)
#let show-hour-lines(bounds, notable) = {
for hour in notable {
let vpos = time.absolute(bounds, hour)
// This is a hack: we need to rescale to the size of the table without titles
let real_vpos = (vpos * (100% - title_ratio) + title_ratio) * table_ratio
place(
top + left,
dx: 0%,
dy: real_vpos,
line(
length: 100%,
stroke: (
paint: gray.lighten(70%),
thickness: 0.1pt,
),
),
)
place(
top + left,
dx: 0%,
dy: real_vpos,
text(fill: gray.darken(40%), hour.label),
)
}
}
#let show-classes(chosen, all, day-bounds) = {
tt.is(tt.array(classes.Class), chosen)
tt.is(tt.array(classes.TimeClass), all)
tt.is(time.Bounds, day-bounds)
let class_cell(class, dy: 0pt, dx: 0pt, height: none, width: none) = {
place(
top + left,
dx: dx,
dy: dy,
cell.with(height: height, width: width, fill: class.descr.color)()[
#align(center, (class.descr.fmt)(class.descr.name, class.descr.uid, class.descr.teacher, class.room))
]
)
}
for (idx, class) in all.enumerate() {
if class.descr in chosen {
let (width, dx) = if class.sem.len() == 1 {
let available_width_per_sem = (100% - small_gutter) / 2
(available_width_per_sem, (available_width_per_sem + small_gutter) * (class.sem.at(0) - 1))
} else {
(100%, 0%)
}
let dy = time.absolute(day-bounds, class.start)
let height = time.proportional(day-bounds, class.len)
class_cell(class, dy: dy, dx: dx, height: height, width: width)
}
}
}
#let day(name, chosen, d, day-bounds) = {
tt.is(tt.str, name)
tt.is(tt.array(classes.Class), chosen)
tt.is(classes.Day, d)
tt.is(time.Bounds, day-bounds)
grid(
columns: (100%,),
rows: (title_ratio, 100% - title_ratio),
align(center, text(size: 18pt, weight: "bold")[#name]),
show-classes(chosen, d, day-bounds),
)
}
#let conf(
week,
chosen,
) = {
tt.is(classes.Week, week)
tt.is(tt.array(classes.Class), chosen)
set page(
paper: "presentation-16-9",
margin: 0.5cm,
)
let day-bounds = time.empty
let notable-hours = ()
let ects = 0
for day in ( week.mon, week.tue, week.wed, week.thu, week.fri ) {
for class in day {
if class.descr in chosen {
ects += class.ects
let start = class.start
let end = time.offset(class.start, class.len)
day-bounds = time.extend(day-bounds, start)
day-bounds = time.extend(day-bounds, end)
if start not in notable-hours { notable-hours.push(start) }
if end not in notable-hours { notable-hours.push(end) }
}
}
}
show-hour-lines(day-bounds, notable-hours)
grid(
columns: (4%, 1fr, 1fr, 1fr, 1fr, 1fr, 0.1%),
gutter: (large_gutter,),
row-gutter: (large_gutter,),
rows: (table_ratio,),
[],
day("Monday", chosen, week.mon, day-bounds),
day("Tuesday", chosen, week.tue, day-bounds),
day("Wednesday", chosen, week.wed, day-bounds),
day("Thursday", chosen, week.thu, day-bounds),
day("Friday", chosen, week.fri, day-bounds),
[],
)
text(size: 12pt)[Totalling * #ects * ECTS]
}