-
Notifications
You must be signed in to change notification settings - Fork 7
/
example-sdr-2.html
62 lines (51 loc) · 1.69 KB
/
example-sdr-2.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>2D SDR Drawing</title>
<style>
body { margin: 10px; }
svg {
border: solid 1px orange;
}
</style>
</head>
<body>
<svg id="receptiveFieldDemo"></svg>
<br/>
<input type="range" min="0" max="100" value="90" id="receptiveFieldPercSlider" />
receptive field: <span class="receptiveFieldPercDisplay"></span>%
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://d3js.org/d3.v5.min.js"></script>
<script src="dist/cell-viz-2d-1.4.6.min.js"></script>
<script>
$(function() {
function getRandomReceptiveField(receptiveFieldPerc, dimensions) {
let n = dimensions
let w = parseInt(receptiveFieldPerc * n)
let potentialPool = SdrUtils.getRandom(n, w)
return potentialPool
}
let inputSpace = 1000
let $receptiveFieldPercSlider = $('#receptiveFieldPercSlider')
let $receptiveFieldPercDisplay = $('.receptiveFieldPercDisplay')
let drawOptions = {
width: 560,
height: 300,
}
let pool = getRandomReceptiveField(.5, inputSpace)
function renderDisplay() {
$receptiveFieldPercDisplay.html($receptiveFieldPercSlider.val())
let rcDrawing = new SdrDrawing(pool, 'receptiveFieldDemo')
rcDrawing.draw(drawOptions)
}
renderDisplay()
$receptiveFieldPercSlider.on('input', () => {
let targetDensity = parseInt($receptiveFieldPercSlider.val()) / 100
pool = SdrUtils.adjustTo(pool, targetDensity)
renderDisplay()
})
});
</script>
</body>
</html>