-
Notifications
You must be signed in to change notification settings - Fork 7
/
showcase.nim
217 lines (190 loc) · 6.11 KB
/
showcase.nim
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
import nimib
import nimiSlides
nbInit(theme = revealTheme)
nb.useLatex()
when defined(themeWhite):
nb.filename = "./showcase_white.html"
setSlidesTheme(White)
else:
setSlidesTheme(Moon)
useScrollWheel()
showSlideNumber()
footer("You can have a footer. It's handy for [links](https://github.com/HugoGranstrom/nimiSlides)")
slide:
bigText: "Welcome to [nimiSlides](https://github.com/HugoGranstrom/nimiSlides)! 🛷"
nbText: "These slides will show you what this [nimib](https://github.com/pietroppeter/nimib) theme is capable of."
speakerNote "This is a note"
slide:
slide:
nbText: "You can have text, but also code:"
nbCode:
let a = 2
let b = 3
echo a * b
nbText: "Look! 👆 It even runs the code and shows the output!"
nbText: "Next slide this way ↓"
slide:
nbText: "You can animate the code as well! 🎞"
animateCode(1, 3..4, 5):
echo "First this!"
echo "But not this!"
echo "Then..."
echo "...these"
echo "And last this!"
nbClearOutput()
nbText: "Pretty cool if you ask me! 😎"
slide:
speakerNote "This is another note"
nbText: "## Typewriter Effect"
typewriter("This text will be typed one letter at a time with the speed and alignement specified.",
typeSpeed=30, alignment="left")
slide:
slide:
bigText: "Fragments (animations)"
fragmentEnd(semiFadeOut):
fragmentFadeIn:
nbText: "### Who doesn't like animations? ▶"
fragmentFadeIn(strike):
nbText: "Strike!"
fragmentFadeIn(highlightGreen):
nbText: "Green!"
fragmentFadeIn(@[grows], @[shrinks], @[fadeOut]):
nbText: "fadeIn > grows > shrinks > fadeOut"
fragmentFadeIn:
nbText: "And now that all is finished, semiFadeOut everything!"
slide:
nbText: "### You can do pretty complex animations:"
fragmentEnd(fadeOut):
fragmentFadeIn:
nbText: "First show something here"
fragmentFadeIn:
nbText: "And when we are done here, hide this and show the next part"
fragmentFadeIn:
nbText: "Abra kadabra! 🧙"
fragmentFadeIn:
nbText: "Where did it go?"
slide:
nbText: "### Using a for loop you can automate tedious repetition"
let texts = ["First", "Second", "Third", "Fourth", "Fifth"]
for text in texts:
fragment(highlightCurrentBlue):
nbText: text
slide(slideOptions(autoAnimate=true)):
nbText: "## Automatic animation"
nbText: """
- One element
"""
slide(slideOptions(autoAnimate=true)):
nbText: "## Automatic animation"
nbText: """
- One element
- Two elements
"""
slide(slideOptions(autoAnimate=true)):
nbText: "## Automatic animation"
nbText: """
- One element
- Two elements
- Three elements
"""
slide:
nbText: "## Fragment list"
fragmentList(@[
"First",
"Second",
"Third"
], fadeIn)
slide:
nbText: md"""
# Math ➕
You can show off all your fancy equations ⚛
$$ e^{\pi i} = -1 $$
$$ \int_0^{\infty} \frac{1}{1 + e^x} dx$$
"""
slide:
slide:
nbText: md"""
# Images 🖼️
You can have the code generating an image in the slides and then load the image. This way it's always up to date!
"""
animateCode(1, 2..5, 6..9, 10..11, 12):
import numericalnim, ggplotnim, std/[sequtils, math]
# Coarse grid sampled spline
let xSample = linspace(0.0, 1.0, 20)
let ySample = xSample.mapIt(sin(20*it))
let spline = newHermiteSpline(xSample, ySample)
# Dense grid
let x = linspace(0.0, 1.0, 100)
let y = x.mapIt(sin(20*it))
let ySpline = spline.eval(x)
# Build dataframe
var df = toDf({"x": x, "exact": y, "spline": ySpline})
df = df.gather(["exact", "spline"], value="y", key="type")
slide:
nbText: "### Now let's load the image we just created!"
nbCode:
ggplot(df, aes("x", "y", color="type")) +
geom_line() +
ggsave("images/splineComp.png")
nbClearOutput() # this hides the usual ggplotnim hint that is printed normally
fragment(fadeUp):
nbImage("images/splineComp.png")
slide:
slide(slideOptions(colorBackground="#f1b434")):
nbText: "You can have different backgrounds"
slide(slideOptions(imageBackground="https://images.freeimages.com/images/large-previews/3d0/london-1452422.jpg")):
nbText: "Image background"
slide(slideOptions(videoBackground="https://user-images.githubusercontent.com/5092565/178597724-16287a00-5c31-4500-83d8-e07160a36369.mp4")):
nbText: "Video background"
slide(slideOptions(iframeBackground="https://pietroppeter.github.io/nimib/", iframeInteractive=true)):
nbText: "Iframe background"
slide:
slide:
nbText: "## 2 Columns"
columns:
column:
nbText: "Left"
column:
nbText: "Right"
slide:
nbText: "## 3 Columns"
columns:
column:
nbText: "Left"
column:
nbText: "Middle"
column:
nbText: "Right"
slide:
nbText: "### columns vs adaptiveColumns"
columns:
column:
nbText: "Using `columns`, all columns will have the same width..."
column:
nbText: "... regardless of their content."
adaptiveColumns:
column:
nbText: "Using `adaptiveColumns`, a columns will only take the space it needs..."
column:
nbText: "... like this."
slide:
nbText: "## Incremental lists"
align("left"):
orderedList:
listItem(@[fadeInThenSemiOut, highlightCurrentGreen]):
nbText: "First"
listItem(@[fadeInThenSemiOut, highlightCurrentGreen]):
nbText: "Second"
unorderedList:
listItem(@[fadeInThenSemiOut, highlightCurrentGreen]):
nbText: "You can nest them as well"
orderedList:
listItem(@[fadeInThenSemiOut, highlightCurrentGreen]):
nbText: "And mix ordered and unordered lists"
slide:
nbText: "## Corner images"
cornerImage("https://hugogranstrom.com/images/avatar.png", LowerLeft, 100)
cornerImage("https://hugogranstrom.com/images/avatar.png", LowerRight, 100)
cornerImage("https://hugogranstrom.com/images/avatar.png", UpperLeft, 100)
cornerImage("https://hugogranstrom.com/images/avatar.png", UpperRight, 100)
nbSave()