Skip to content

Commit

Permalink
Transform pdfpc config into single function
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasKroepelin committed Aug 25, 2023
1 parent be55d35 commit ec90212
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 35 deletions.
2 changes: 1 addition & 1 deletion examples/gauss.pdfpc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"pdfpcFormat":2,"duration":15,"startTime":"08:15","disableMarkdown":false,"noteFontSize":5,"defaultTransition":"push:0.3","endSlide":9,"savedSlide":3,"pages":[{"idx":0,"label":1,"overlay":0,"forcedOverlay":false,"hidden":false},{"idx":1,"label":2,"overlay":0,"forcedOverlay":false,"hidden":false},{"idx":2,"label":3,"overlay":0,"forcedOverlay":false,"hidden":false,"note":"Remember to explain Sigma notation!"},{"idx":3,"label":4,"overlay":0,"forcedOverlay":false,"hidden":false},{"idx":4,"label":5,"overlay":0,"forcedOverlay":false,"hidden":false},{"idx":5,"label":6,"overlay":0,"forcedOverlay":false,"hidden":true},{"idx":6,"label":7,"overlay":0,"forcedOverlay":false,"hidden":false,"note":"# How the last steps work\nWe use _basic algebra_ rules for the last steps."},{"idx":7,"label":7,"overlay":1,"forcedOverlay":true,"hidden":false,"note":"# How the last steps work\nWe use _basic algebra_ rules for the last steps."},{"idx":8,"label":7,"overlay":2,"forcedOverlay":true,"hidden":false,"note":"# How the last steps work\nWe use _basic algebra_ rules for the last steps."},{"idx":9,"label":7,"overlay":3,"forcedOverlay":true,"hidden":false,"note":"# How the last steps work\nWe use _basic algebra_ rules for the last steps."},{"idx":10,"label":7,"overlay":4,"forcedOverlay":true,"hidden":false,"note":"# How the last steps work\nWe use _basic algebra_ rules for the last steps."},{"idx":11,"label":8,"overlay":0,"forcedOverlay":false,"hidden":false},{"idx":12,"label":9,"overlay":0,"forcedOverlay":false,"hidden":false},{"idx":13,"label":10,"overlay":0,"forcedOverlay":false,"hidden":false},{"idx":14,"label":11,"overlay":0,"forcedOverlay":false,"hidden":false}]}
{"pdfpcFormat":2,"duration":15,"startTime":"08:15","disableMarkdown":false,"noteFontSize":5,"defaultTransition":"push:0.3:180:horizontal:outward","endSlide":9,"savedSlide":3,"pages":[{"idx":0,"label":1,"overlay":0,"forcedOverlay":false,"hidden":false},{"idx":1,"label":2,"overlay":0,"forcedOverlay":false,"hidden":false},{"idx":2,"label":3,"overlay":0,"forcedOverlay":false,"hidden":false,"note":"Remember to explain Sigma notation!"},{"idx":3,"label":4,"overlay":0,"forcedOverlay":false,"hidden":false},{"idx":4,"label":5,"overlay":0,"forcedOverlay":false,"hidden":false},{"idx":5,"label":6,"overlay":0,"forcedOverlay":false,"hidden":true},{"idx":6,"label":7,"overlay":0,"forcedOverlay":false,"hidden":false,"note":"# How the last steps work\nWe use _basic algebra_ rules for the last steps."},{"idx":7,"label":7,"overlay":1,"forcedOverlay":true,"hidden":false,"note":"# How the last steps work\nWe use _basic algebra_ rules for the last steps."},{"idx":8,"label":7,"overlay":2,"forcedOverlay":true,"hidden":false,"note":"# How the last steps work\nWe use _basic algebra_ rules for the last steps."},{"idx":9,"label":7,"overlay":3,"forcedOverlay":true,"hidden":false,"note":"# How the last steps work\nWe use _basic algebra_ rules for the last steps."},{"idx":10,"label":7,"overlay":4,"forcedOverlay":true,"hidden":false,"note":"# How the last steps work\nWe use _basic algebra_ rules for the last steps."},{"idx":11,"label":8,"overlay":0,"forcedOverlay":false,"hidden":false},{"idx":12,"label":9,"overlay":0,"forcedOverlay":false,"hidden":false},{"idx":13,"label":10,"overlay":0,"forcedOverlay":false,"hidden":false},{"idx":14,"label":11,"overlay":0,"forcedOverlay":false,"hidden":false}]}
10 changes: 6 additions & 4 deletions examples/gauss.typ
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
footer: [Sum of natural numbers, CF Gauß],
)

#pdfpc.duration-minutes(15)
#pdfpc.start-time(datetime(hour: 8, minute: 15, second: 0))
#pdfpc.note-font-size(5)
#pdfpc.default-transition("push:0.3")
#pdfpc.config(
duration-minutes: 15,
start-time: datetime(hour: 8, minute: 15, second: 0),
note-font-size: 5,
default-transition: (type: "push", duration-seconds: 0.3),
)

#title-slide(
authors: "Carl Friedrich Gauß",
Expand Down
92 changes: 62 additions & 30 deletions utils/pdfpc.typ
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,74 @@
#metadata((t: "HiddenSlide")) <pdfpc>
]

#let duration-minutes(minutes) = [
#metadata((t: "Duration", v: minutes)) <pdfpc>
]
#let config(
duration-minutes: none,
start-time: none,
end-time: none,
last-minutes: none,
note-font-size: none,
disable-markdown: false,
default-transition: none,
) = {
if duration-minutes != none {
[ #metadata((t: "Duration", v: duration-minutes)) <pdfpc> ]
}

#let _time-config(time, msg-name, tag-name) = {
let time = if type(time) == "datetime" {
time.display("[hour padding:zero repr:24]:[minute padding:zero]")
} else if type(time) == "string" {
time
} else {
panic(msg-name + " must be either a datetime or a string in the HH:MM format.")
let _time-config(time, msg-name, tag-name) = {
let time = if type(time) == "datetime" {
time.display("[hour padding:zero repr:24]:[minute padding:zero]")
} else if type(time) == "string" {
time
} else {
panic(msg-name + " must be either a datetime or a string in the HH:MM format.")
}

[ #metadata((t: tag-name, v: time)) <pdfpc> ]
}

[ #metadata((t: tag-name, v: time)) <pdfpc> ]
}
if start-time != none {
_time-config(start-time, "Start time", "StartTime")
}

#let start-time(time) = {
_time-config(time, "Start time", "StartTime")
}
if end-time != none {
_time-config(end-time, "End time", "EndTime")
}

#let end-time(time) = {
_time-config(time, "End time", "EndTime")
}
if last-minutes != none {
[ #metadata((t: "LastMinutes", v: last_minutes)) <pdfpc> ]
}

#let last-minutes(minutes) = [
#metadata((t: "LastMinutes", v: minutes)) <pdfpc>
]
if note-font-size != none {
[ #metadata((t: "NoteFontSize", v: note-font-size)) <pdfpc> ]
}

#let note-font-size(font-size) = [
#metadata((t: "NoteFontSize", v: font-size)) <pdfpc>
]
[ #metadata((t: "DisableMarkdown", v: disable-markdown)) <pdfpc> ]

#let disable-markdown(disabled) = [
#metadata((t: "DisableMarkdown", v: disabled)) <pdfpc>
]
if default-transition != none {
let dir-to-angle(dir) = if dir == ltr {
"0"
} else if dir == rtl {
"180"
} else if dir == ttb {
"90"
} else if dir == btt {
"270"
} else {
panic("angle must be a direction (ltr, rtl, ttb, or btt)")
}

#let default-transition(default) = [
#metadata((t: "DefaultTransition", v: default)) <pdfpc>
]
let transition-str = (
default-transition.at("type", default: "replace")
+ ":" +
str(default-transition.at("duration-seconds", default: 1))
+ ":" +
dir-to-angle(default-transition.at("angle", default: rtl))
+ ":" +
default-transition.at("alignment", default: "horizontal")
+ ":" +
default-transition.at("direction", default: "outward")
)

[ #metadata((t: "DefaultTransition", v: transition-str)) <pdfpc> ]
}
}

0 comments on commit ec90212

Please sign in to comment.