This commit is contained in:
Schrottkatze 2025-02-16 22:50:01 +01:00
commit e9cd7b41c2
Signed by: schrottkatze
SSH key fingerprint: SHA256:FPOYVeBy3QP20FEM42uWF1Wa/Qhlk+L3S2+Wuau/Auo
4 changed files with 132 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.pdf

83
präsi-test.typ Normal file
View file

@ -0,0 +1,83 @@
#let pgcounter = context [
real page: #here().page() / #counter(page).final().first()
];
#set page(
paper: "presentation-16-9",
fill: rgb("222"),
footer: align(center, pgcounter),
)
#set text(fill: white)
#let s_topic = state("topic", (color: red));
#let seite(n) = [#page(
background: context {
import "@preview/cetz:0.3.2"
let pages = query(selector(<seite>).before(query(selector(<seite>).after(here())).first().location()))
let last = counter(<seite>).final().first()
let size = 100 / last
[
#place(
bottom + left,
stack(dir: ltr, ..pages.map(pg => {
let seg_start = ((counter(<seite>).at(pg.location()).first() + 1) / last) * 100 - 50;
link(pg.location(), box(width: size * 1%, height: 0.5%))
}),)
)
#place(
bottom + left,
cetz.canvas(
length: 1%,
{
import cetz.draw: *
for pg in pages.rev() {
let seg_start = ((counter(<seite>).at(pg.location()).first() + 1) / last) * 100 - 50
rect((seg_start - size - 0.1, 0), (seg_start, 0.5), fill: s_topic.at(pg.location()).color, stroke: none)
}
},
),
)
]
},
)[#lorem(n * 20)
#align(bottom)[#text(size: 4em)[Slide #n]
]
] <seite>];
#let s = state("foo", "bar");
#for i in (1, 2, 3, 4) {
seite(i)
}
#s_topic.update((color: blue))
#for i in (5, 6, 7) {
seite(i)
}
#page[= miau 1]
#page[= miau 2]
#s_topic.update((color: green))
#for i in (8, 9) {
seite(i)
}
#page[= miau 3]
#s_topic.update((color: yellow))
#for i in (10, 11, 12) {
seite(i)
}
#text(context s.get())

30
src/lib.typ Normal file
View file

@ -0,0 +1,30 @@
#let s_topic_list = state("topics", ())
#let s_topic = state("topic", 0)
#let init-presentation(topics: ()) = {
// validation hell :3
if type(topics) != "array" {
panic("Expected array of topics.")
}
if not (
topics.all(it => type(it) == "string" or type(it) == content)
or topics.all(it => type(it) == "color")
or topics.all(it => (
it.len() == 2
and (
(type(it.first()) == "string" or type(it.first() == "content")) and type(it.last()) == "color"
)
))
) {
// TODO: more specific error, telling the exact wrong indices
panic("topics expected a uniform array of: ", "string | content", "color", "(string | content, color)")
}
s_topic_list.update(topics)
}
#let slide(paper: "presentation-16-9", body) = [
#page(paper: paper)[
#body
] <slide>
]

18
test.typ Normal file
View file

@ -0,0 +1,18 @@
#import "src/lib.typ": init-presentation, slide;
#init-presentation(
topics: (
("Red", red),
("Green", green),
("Blue", blue),
("Yellow", yellow),
("Magenta", purple),
),
)
#set page(fill: rgb("222"))
#set text(fill: white)
#slide[
= Big Title Slide
]