sense_the_rythm

rythm game for ESense Earable
git clone git://source.orangerot.dev:/university/sense_the_rythm.git
Log | Files | Refs | README | LICENSE

kit-slides.typ (8139B)


      1 //==========================================================
      2 // Karlsruhe Institute of Technology theme for Typst slides.
      3 // Based on the official Powerpoint Theme and Latex Template
      4 //
      5 // You don't need to edit this file. Only presentation.typ
      6 // =========================================================
      7 #import "@preview/polylux:0.3.1": *
      8 
      9 #let _kit-outer-margin = 3mm
     10 #let _kit-inner-margin = 11mm
     11 #let _kit-top-margin = 10mm
     12 #let _kit-bottom-margin = 11mm
     13 
     14 #let kit-green = rgb(0, 150, 130)
     15 #let kit-blue = rgb(70, 100, 170)
     16 #let green = kit-green
     17 #let blue = kit-blue
     18 #let black70 = rgb(64, 64, 64)
     19 #let brown = rgb(167, 130, 46)
     20 #let purple = rgb(163, 16, 124)
     21 #let cyan = rgb(35, 161, 224)
     22 #let lime = rgb(140, 182, 60)
     23 #let yellow = rgb(252, 229, 0)
     24 #let orange = rgb(223, 155, 27)
     25 #let red = rgb(162, 34, 35)
     26 
     27 #let kit-title = state("kit-title", [])
     28 #let kit-subtitle = state("kit-subtitle", [])
     29 #let kit-short-title = state("kit-short-title", none)
     30 #let kit-author = state("kit-author", [])
     31 #let kit-short-author = state("kit-short-author", none)
     32 #let kit-group-logo = state("kit-group-logo", none)
     33 #let kit-institute = state("kit-institute", [])
     34 #let kit-date = state("kit-date", none)
     35 #let kit-show-page-count = state("kit-show-page-count", false)
     36 
     37 //=================
     38 // Helper functions
     39 //=================
     40 
     41 #let kit-logo(..rest) = context {
     42   if text.lang == "de" {
     43     image("/assets/kit/logo-de.svg", ..rest)
     44   } else {
     45     image("/assets/kit/logo-en.svg", ..rest)
     46   }
     47 }
     48 
     49 #let kit-rounded-block(radius: 3mm, body) = {
     50   block(
     51     radius: (
     52       top-right: radius,
     53       bottom-left: radius,
     54     ),
     55     clip: true,
     56     body,
     57   )
     58 }
     59 
     60 #let kit-list-marker = move(
     61   dy: 0.125em,
     62   kit-rounded-block(
     63     radius: 0.15em,
     64     rect(
     65       // The latex documentclass uses a size of 1ex, but type only supports em.
     66       width: 0.5em,
     67       height: 0.5em,
     68       fill: kit-green,
     69     ),
     70   ),
     71 )
     72 
     73 #let kit-theme(
     74   title: none,
     75   subtitle: none,
     76   short-title: none,
     77   author: none,
     78   short-author: none,
     79   language: "de",
     80   group-logo: none,
     81   institute: none,
     82   date: none,
     83   aspect-ratio: "16-9",
     84   show-page-count: false,
     85   body,
     86 ) = {
     87 
     88   if language not in ("en", "de") {
     89     panic("Only English (en) and German (de) are currently supported")
     90   }
     91   set page(margin: 0pt, header-ascent: 0pt, footer-descent: 0pt)
     92   // Use power point page sizes, as they differ from default typst page sizes.
     93   set page(width: 25.4cm, height: 14.29cm) if aspect-ratio == "16-9"
     94   set page(width: 25.4cm, height: 15.88cm) if aspect-ratio == "16-10"
     95   set page(width: 25.4cm, height: 19.05cm) if aspect-ratio == "4-3"
     96   if aspect-ratio not in ("16-9", "16-10", "4-3") {
     97     panic("Unsupported aspect ratio")
     98   }
     99 
    100   set text(lang: language, font: ("Arial", "Helvetica", "Roboto"))
    101 
    102   set list(marker: kit-list-marker)
    103 
    104   kit-title.update(title)
    105   kit-subtitle.update(subtitle)
    106   if short-title == none {
    107     kit-short-title.update(title)
    108   } else {
    109     kit-short-title.update(short-title)
    110   }
    111   kit-author.update(author)
    112   if short-author == none {
    113     kit-short-author.update(author)
    114   } else {
    115     kit-short-author.update(short-author)
    116   }
    117   kit-institute.update(institute)
    118   kit-group-logo.update(group-logo)
    119   kit-date.update(date)
    120   kit-show-page-count.update(show-page-count)
    121 
    122   body
    123 }
    124 
    125 //=================
    126 // slides
    127 //=================
    128 
    129 #let title-slide(banner: none) = {
    130   show: polylux-slide
    131   if banner == none {
    132     banner = image("/assets/kit/banner.jpg")
    133   }
    134 
    135   // Top half
    136   pad(left: _kit-inner-margin, right: 6mm, top: _kit-top-margin)[
    137     // KIT logo
    138     #place[
    139       #kit-logo(width: 45mm)
    140     ]
    141     // Group logo
    142     #place(right)[
    143       #block(width: 30mm, height: 30mm)[
    144         #set image(width: 100%)
    145         #context kit-group-logo.get()
    146       ]
    147     ]
    148     // Title
    149     #place(dy: 32mm, text(weight: "bold", size: 26pt, kit-title.display()))
    150     // Subtitle
    151     #place(dy: 44mm)[
    152       #set text(weight: "bold", size: 18pt)
    153       #set par(leading: 0.3em)
    154       #kit-subtitle.display()
    155     ]
    156   ]
    157 
    158   // Bottom half
    159   align(
    160     bottom,
    161     pad(x: _kit-outer-margin)[
    162       // Banner
    163       #block(height: 60mm, below: 0pt)[
    164         #kit-rounded-block(radius: 3mm)[
    165           #set image(width: 100%, height: 100%)
    166           #banner
    167         ]
    168       ]
    169       // Footer
    170       #block(height: _kit-bottom-margin, width: 100%)[
    171         #grid(
    172           columns: (auto, 1fr),
    173           [
    174             #align(left + horizon)[
    175               #block(height: 100%)[
    176                 #set text(size: 8pt)
    177                 #context {
    178                   if text.lang == "en" [
    179                     KIT - The Research University in the Helmholtz Association
    180                   ] else if text.lang == "de" [
    181                     KIT - Die Forschungsuniversität in der Helmholtz-Gemeinschaft
    182                   ]
    183                 }
    184               ]
    185             ]
    186           ],
    187           [
    188             #align(
    189               right + horizon,
    190               block(height: 100%)[
    191                 #link(
    192                   "https://www.kit.edu",
    193                   text("www.kit.edu", weight: "bold", size: 16.5pt),
    194                 )
    195               ],
    196             )
    197           ],
    198         )
    199       ]
    200     ],
    201   )
    202 }
    203 
    204 #let slide(title: [], body) = {
    205   // Title bar
    206   let header = block(width: 100%, height: 100%, inset: (x: _kit-inner-margin))[
    207     #grid(
    208       columns: (auto, 1fr),
    209       [
    210         #set text(24pt, weight: "bold")
    211         // We need a block here to force the grid to take the full height of the surrounding block
    212         #block(height: 100%)[
    213           #align(left + bottom, title)
    214         ]
    215       ],
    216       [
    217         #align(right + bottom)[
    218           #kit-logo(width: 30mm)
    219         ]
    220       ],
    221     )
    222   ]
    223 
    224   // Content block
    225   let wrapped-body = block(
    226     width: 100%,
    227     height: 100%,
    228     inset: (x: _kit-inner-margin, top: 15.5mm),
    229   )[
    230     #set text(18pt)
    231     // Default value, but had to be changed for layout
    232     #set block(above: 1.2em)
    233     #body
    234   ]
    235 
    236   // Footer
    237   let footer = block(width: 100%, inset: (x: _kit-outer-margin))[
    238     #set block(above: 0pt)
    239     #set text(size: 9pt)
    240     #line(stroke: rgb("#d8d8d8"), length: 100%)
    241     #block(width: 100%, height: 100%)[
    242       #align(horizon)[
    243         #grid(
    244           columns: (20mm, 30mm, 1fr, auto),
    245           pad(
    246             left: 6mm,
    247             context if kit-show-page-count.get() [
    248               #logic.logical-slide.display()/#strong(utils.last-slide-number)
    249             ] else [
    250               #logic.logical-slide.display()
    251             ],
    252           ),
    253           kit-date.display(),
    254           [#kit-short-author.display() - #kit-short-title.display()],
    255           align(right, kit-institute.display()),
    256         )
    257       ]
    258     ]
    259   ]
    260 
    261   set page(
    262     header: header,
    263     footer: footer,
    264     margin: (top: 22.5mm, bottom: _kit-bottom-margin),
    265   )
    266   polylux-slide(wrapped-body)
    267 }
    268 
    269 // This function is left here for backwards compatibility only. Please use #slide(side-by-side[][]) instead.
    270 #let split-slide(title: [], body-left, body-right) = {
    271   let body = grid(
    272     columns: (1fr, 1fr),
    273     gutter: 2em,
    274     body-left, body-right,
    275   )
    276 
    277   slide(title: title, body)
    278 }
    279 
    280 #let kit-color-block(title: [], color: [], body) = {
    281   // 80% is a rough heuristic, that produces the correct result for all predefined colors.
    282   // Might be adjusted in the future
    283   let title-color = if luma(color).components().at(0) >= 80% {
    284     black
    285   } else {
    286     white
    287   }
    288   kit-rounded-block()[
    289     #block(
    290       width: 100%,
    291       inset: (x: 0.5em, top: 0.3em, bottom: 0.4em),
    292       fill: gradient.linear(
    293         (color, 0%),
    294         (color, 87%),
    295         (color.lighten(85%), 100%),
    296         dir: ttb,
    297       ),
    298       text(fill: title-color, title),
    299     )
    300     #set text(size: 15pt)
    301     #block(
    302       inset: 0.5em,
    303       above: 0pt,
    304       fill: color.lighten(85%),
    305       width: 100%,
    306       body,
    307     )
    308   ]
    309 }
    310 
    311 #let kit-info-block(title: [], body) = {
    312   kit-color-block(title: title, color: kit-green, body)
    313 }
    314 
    315 #let kit-example-block(title: [], body) = {
    316   kit-color-block(title: title, color: kit-blue, body)
    317 }
    318 
    319 #let kit-alert-block(title: [], body) = {
    320   kit-color-block(title: title, color: red.lighten(10%), body)
    321 }