-
Notifications
You must be signed in to change notification settings - Fork 4
/
index-0.5.html
66 lines (60 loc) · 1.95 KB
/
index-0.5.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
63
64
65
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"></meta>
<title>Punctual</title>
<link href="style.css" rel="stylesheet" type="text/css"/>
</head>
<body onLoad="window.doLaunch()">
<script type="module">
import * as P from "./punctual.js";
window.doLaunch = function () {
var cvs = document.getElementById('canvas');
window.punctual = new P.Punctual();
window.requestAnimationFrame(animate);
}
function animate() {
window.requestAnimationFrame(animate);
var now = Date.now()/1000.0;
window.punctual.preRender({canDraw: true, nowTime: now});
window.punctual.render({canDraw: true, zone:0, nowTime: now});
window.punctual.postRender({canDraw: true, nowTime: now});
}
window.doEval = function () {
var t = document.getElementById("editorArea").value;
var r = window.punctual.define({zone:0,text:t,time: Date.now()/1000.0});
console.log(r);
document.getElementById('errors').textContent = r.error;
}
window.addEventListener('keydown', function (e) {
e = e || window.event;
if(e.shiftKey && e.key=="Enter") {
e.preventDefault();
window.doEval();
}
});
</script>
<div id="canvasDiv"><canvas id="canvas"></canvas></div>
<div class="editorAndStatus">
<div class="editor">
<textarea class="editorArea" id="editorArea">
-- Punctual, an audiovisual live coding language, version 0.5
-- Press Shift-Enter to (re)evaluate/activate code
-- documentation @ https://github.com/dktr0/Punctual.git
-- help/discussion @ Estuary discord server
x1 << osc $ 0.11*[1,2]; y1 << osc $ 0.08/[3,4];
x2 << osc $ 0.06/[5,6]; y2 << osc $ 0.04*[7,8];
ls << mono $ iline [x1,y1] [x2,y2] 0.002;
col << hsvrgb [osc 0.11,0.5 ~~ 1 $ osc 0.12, 1];
mask << prox 0 ** 8;
a << fit 1 $ ls * col * mask;
gatep 0.1 (maxp a (fb fxy * 0.98)) >> add <> 5
</textarea>
</div>
<div class="status">
<!-- <button onClick="doEval()">eval</button> -->
<span id="errors"></span>
</div>
</div>
</body>
</html>