Last active
May 14, 2021 09:59
-
-
Save andybak/dfcea3b47dd624057d397482a0ea6a9e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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