Hugo Granström
NimConf 2022
Powered by Nim 👑
Elegant DSL-based API
Easy to use
Leverages Nim's flexible syntax
The easiest way to create a slideshow in Nim, about Nim
Customizable
Easy to extend
Custom blocks
Outputs HTML
Powerful
Nim's meta programming
Templates
Simplify repetitive patterns
Macros
Code blocks are compiled and run
Captures code output
Automation
Generate plots - always up to date
for-loops
The basics of nimiSlides
Feature exploration
Practical examples
nbText: """
### Header
Text can be *italic*, **bold** or ~~crossed over~~.
- List item 1
- List item 2
[A Link](https://github.com/HugoGranstrom/nimiSlides)
"""
nimble install nimiSlides
import nimib, nimiSlides
nbInit(theme = revealTheme)
slide:
nbText: "1"
slide:
nbText: "2"
slide:
slide:
nbText: "3"
slide:
nbText: "4"
slide:
nbText: "5"
1 ➡️ 2 ➡️ 3
⬇️
4
⬇️
5
let a = 1
let b = 2
echo a + b
3
nbCode:
let a = 1
let b = 2
echo a + b
let a = 1
let b = 2
echo a + b
3
echo 1
echo 2
echo 3
echo 4
echo 5
1 2 3 4 5
animateCode(1, 3..4, 2, 3..5):
echo 1
echo 2
echo 3
echo 4
echo 5
echo 1
echo 2
echo 3
echo 4
echo 5
1 2 3 4 5
It works for long codes as well
echo "1"
echo 2
echo 3
echo 4
echo 5
echo "1"
echo 2
echo 3
echo 4
echo 5
echo "1"
echo 2
echo 3
echo 4
echo 5
echo "1"
echo 2
echo 3
echo 4
echo 5
echo "1"
echo 2
echo 3
echo 4
echo 5
echo "1"
echo 2
echo 3
echo 4
echo 5
typewriter("This text will be typed, one char at a time")
fragmentFadeIn:
nbText: "First"
fragmentFadeIn:
nbText: "Second"
First
Second
fragment(grows):
fragment(shrinks):
nbText: "This will grow, then shrink"
This will grow, then shrink
fragmentEnd(semiFadeOut):
fragmentFadeIn:
nbText: "First"
fragmentFadeIn:
nbText: "Second"
First
Second
This appears first
Then this
Then this (nested list)
This is also nested
Back again
unorderedList:
listItem:
nbText: "First item"
unorderedList:
listItem:
nbText: "One level deeper"
listItem(highlightCurrentGreen):
nbText: "Still deep"
listItem(@[highlightCurrentRed]):
nbText: "Back again"
First item
One level deeper
Still deep
Back again
Left
Middle
Right
columns:
column:
nbText: "Left"
column:
nbText: "Middle"
column:
nbText: "Right"
Left
Middle
Right
$e^{\pi i} = -1$
nb.useLatex
nbText: """
This is some inline math: $\alpha^2 + \beta^2 = \gamma^2$
Here we have a standalone equation:
$$e^{\pi i} = -1$$
"""
This is some inline math: $\alpha^2 + \beta^2 = \gamma^2$
Here we have a standalone equation: $$e^{\pi i} = -1$$
speakerNote: "Show the **viewer** this note in the *speaker view*"
slide(slideOptions(colorBackground = "darkviolet")):
nbText: "## Color Background"
slide(slideOptions(imageBackground = "https://github.com/nim-lang/assets/raw/master/Art/logo-crown.png")):
discard
slide(slideOptions(iframeBackground = "https://nim-lang.org/")):
discard
slide(slideOptions(videoBackground = "link/to/videofile.mp4")):
discard
Youtube videos should use Iframes backgrounds
slide(slideOptions(autoAnimate=true)):
nbText: """
- First
"""
slide(slideOptions(autoAnimate=true)):
nbText: """
- First
- Second
"""
slide(slideOptions(autoAnimate=true)):
nbText: """
- First
- Second
- Third
"""
footer: "Hugo Granström *NimConf 2022* - [https://github.com/HugoGranstrom/nimiSlides](https://github.com/HugoGranstrom/nimiSlides)"
cornerImage(
"https://github.com/nim-lang/assets/raw/master/Art/logo-crown.png",
corner=UpperRight)
cornerImage(
"https://github.com/nim-lang/assets/raw/master/Art/logo-crown.png",
corner=LowerRight)
cornerImage(
"https://github.com/nim-lang/assets/raw/master/Art/logo-crown.png",
corner=LowerLeft)
cornerImage(
"https://github.com/nim-lang/assets/raw/master/Art/logo-crown.png",
corner=UpperLeft)
slide(slideOptions(autoAnimate=true)):
nbText: "## Animate header"
slide(slideOptions(autoAnimate=true)):
nbText: "## Animate header"
nbText: "Animate this"
slide(slideOptions(autoAnimate=true)):
nbText: "## Animate header"
nbText: "Animate this"
nbText: "And this"
Let's make our lifes easier and define a template for this!
template slideAutoAnimate(body: untyped) =
slide(slideOptions(autoAnimate=true)):
body
slideAutoAnimate:
nbText: "## Animate header"
slide(slideOptions(autoAnimate=true)):
nbText: "## Animate header"
slide(slideOptions(autoAnimate=true)):
nbText: "## Animate header"
nbText: "Animate this"
slide(slideOptions(autoAnimate=true)):
nbText: "## Animate header"
nbText: "Animate this"
nbText: "And this"
slideAutoAnimate:
nbText: "## Animate header"
slideAutoAnimate:
nbText: "## Animate header"
nbText: "Animate this"
slideAutoAnimate:
nbText: "## Animate header"
nbText: "Animate this"
nbText: "And this"
Example: Histogram of Gaussian for different N
for n in [50, 100, 1000, 10000]:
let filename = &"images/gauss-{n}.png"
let samples = newSeqWith[float](n, gauss(0.0, 1.0))
let df = toDf(samples)
ggplot(df, aes("samples")) +
geom_histogram(fillColor="green") +
ggsave(filename)
slide:
nbText: &"## Gauss Samples (N = {n})"
nbImage(filename)
Thanks for watching 😄
Thanks for watching 😄
Have a great day!
Hugo Granström NimConf 2022 - https://github.com/HugoGranstrom/nimiSlides