-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.qmd
105 lines (86 loc) · 2.26 KB
/
index.qmd
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
---
title: ''
author: ''
format: html
page-layout: full
---
```{r}
#| label: load-packages
#| include: false
library(tidyverse)
library(palmerpenguins)
```
## VM303-01 Studies in Digital Media & Culture
::: {layout="[[49, -2, 49]]"}
```{ojs}
{
let fire = null;
function update(app) {
const width = app.prop("width");
const height = app.prop("height");
if (!fire) fire = createFire(width, height);
updateFire(fire);
drawFire(app, fire);
}
function dispose(app) {
invalidation.then(() => app.dispose());
}
const app = cm.app({
renderer: await cm.terminal(),
frameRate: 15
});
return app.on("update", update).call(dispose).start().node();
}
function createFire(width, height) {
return cm.range(height).map(() => cm.range(width).map(() => 0));
}
function updateFire(fire) {
const h = fire.length;
const w = fire[0].length;
const max = h;
const noise = cm.randomNoise(0, max);
for (let y = 0; y < h - 1; y++) {
for (let x = 0; x < w; x++) {
const decay = cm.randomInt(0, 3);
const spread = cm.randomInt(-1, 1);
const index = Math.min(Math.max(0, x - spread), w - 1);
const target = fire[y + 1][index];
fire[y][x] = Math.max(0, target - decay);
}
}
for (let x = 0; x < w; x++) {
fire[h - 1][x] = noise(x / 10) | 0;
}
}
function drawFire(app, fire) {
const max = fire.length;
app.append(cm.clear, { fill: "black" });
app
.data(fire)
.append(cm.group, { x: 0, y: (_, i) => i })
.data((d) => d)
.append(cm.point, {
y: 0,
x: (_, i) => i,
stroke0: (d) => (d === 0 ? " " : cm.randomChar()),
stroke2: (d) => (d === 0 ? null : d)
})
.transform(cm.mapAttrs, {
stroke2: {
domain: [0, max],
interpolate: d3.interpolateCool
}
});
}
cm = require(await FileAttachment("cm.umd.min.js").url())
import { quote } from "@pearmini/charming-shared"
```
[Department of Visual & Media Arts](https://emerson.edu/academics/academic-departments/visual-media-arts)\
[Emerson College](https://emerson.edu/)\
Spring Semester 2024\
Tues/Thur 16 January---2 May 2024\
6:00-7:45 p.m.\
Ansin Building 604\
[Dr. Martin Roberts](http://mroberts.emerson.build/)\
:::
------------------------------------------------------------------------