-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathroads.html
More file actions
64 lines (58 loc) · 2.3 KB
/
Copy pathroads.html
File metadata and controls
64 lines (58 loc) · 2.3 KB
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
<html>
<head>
<title>Roads</title>
</head>
<body>
<script type="module">
import * as util from 'https://agentscript.org/src/utils.js'
import Animator from 'https://agentscript.org/src/Animator.js'
import TwoDraw from 'https://agentscript.org/src/TwoDraw.js'
import Model from 'https://agentscript.org/models/RoadsModel.js'
// import santafeRoads from 'https://agentscript.org/models/data/santaferoads.json' with { type: 'json' }
const model = new Model() // default world options includes santafeRoads
model.setup()
console.log('model bbox', model.world.bbox)
// const baseMapTile = await util.imagePromise(
// '/models/data/roads14.png'
// )
const view = new TwoDraw(model, {
div: 'modelDiv',
patchSize: 6,
drawOptions: {
// patchesColor: baseMapTile,
patchesColor: 'transparent',
turtlesColor: t =>
({
// nodes: 'red', intersections: 'blue', drivers: 'green'
// nodes: 'transparent', intersections: 'red', drivers: 'green'
nodes: 'rgba(0, 0, 0, 0.2)',
intersections: 'red',
drivers: 'green',
}[t.breed.name]),
turtlesSize: t =>
({
nodes: 1,
intersections: 2,
drivers: 5,
}[t.breed.name]),
turtlesShape: t =>
({
nodes: 'circle',
intersections: 'circle',
drivers: 'dart',
}[t.breed.name]),
linksColor: 'black',
},
})
const anim = new Animator(
() => {
model.step()
view.draw()
},
-1, // run forever
10 // at fps steps/second
)
</script>
<div id="modelDiv"></div>
</body>
</html>