Skip to content

Instantly share code, notes, and snippets.

@hugs
Last active August 29, 2015 14:22
Show Gist options
  • Save hugs/b138ab9a04983bfa36fb to your computer and use it in GitHub Desktop.
Save hugs/b138ab9a04983bfa36fb to your computer and use it in GitHub Desktop.
Draws a circle using a Tapster robot
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