Skip to content

Instantly share code, notes, and snippets.

@andybak
Last active May 14, 2021 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andybak/dfcea3b47dd624057d397482a0ea6a9e to your computer and use it in GitHub Desktop.
Save andybak/dfcea3b47dd624057d397482a0ea6a9e to your computer and use it in GitHub Desktop.
<html>
<head><meta charset='UTF-8'></head>
<body>
<label>Turn: <input id='turn' value='45'></label>
<label>Length: <input id='length' value='2'></label>
<label>Repeats: <input id='repeats' value='6'></label>
<button onclick='run();'>Run</button>
<script>
function run() {
sendCommands([
'brush.color=red',
'brush.size=0.5',
'brush.type=comet',
]);
var turn = document.getElementById('turn').value;
var length = document.getElementById('length').value;
var repeats = parseFloat(document.getElementById('repeats').value);
while (var i=0; i<repeats; i++) {
sendCommands([
`brush.turn=${turn}`,
`brush.draw=${length}`,
`brush.move=-${length}`,
'brush.color.shift=0.015, 0, 0'
]);
}
}
function sendCommands(commands) {
var xmlHttp = new XMLHttpRequest();
var url = '/api/v1?' + commands.join('&');
xmlHttp.open('GET', url, false);
xmlHttp.send(null);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment