Last active
August 29, 2015 14:22
-
-
Save hugs/b138ab9a04983bfa36fb to your computer and use it in GitHub Desktop.
Draws a circle using a Tapster robot
This file contains 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
var centerX=0; | |
var centerY=0; | |
var radius=20; | |
// an array to save your points | |
var points=[]; | |
// populate array with points along a circle | |
for (var degree=0; degree<360; degree++){ | |
var radians = degree * Math.PI/180; | |
var x = centerX + radius * Math.cos(radians); | |
var y = centerY + radius * Math.sin(radians); | |
points.push({x:x,y:y}); | |
} | |
circle = function() { | |
for (var i=0; i<360; i+=1) { | |
setTimeout( function(point) { go(point.x, point.y, -141) }, i*2, points[i]); | |
} | |
} | |
circle() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment