Skip to content

Instantly share code, notes, and snippets.

@klaylton
Created December 15, 2018 22:08
Show Gist options
  • Save klaylton/3910f7c50e1de57a14ad089ed6dcab9b to your computer and use it in GitHub Desktop.
Save klaylton/3910f7c50e1de57a14ad089ed6dcab9b to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/yulamed
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
var stage = document.createElement("canvas");
stage.style.backgroundColor = "black";
stage.style.width = "300";
stage.style.height = "300";
document.body.appendChild(stage);
var ctx = stage.getContext("2d");
var ope = false;
angle = 30;
function draw(){
ctx.beginPath();
ctx.arc(75,75,20, 0, Math.PI*2,true);
ctx.lineWidth = 41;
ctx.strokeStyle = "black";
ctx.stroke();
ctx.beginPath();
ctx.arc(75,75,20, (Math.PI/180)*angle, -(Math.PI/180)*angle);
ctx.lineWidth = 40;
ctx.strokeStyle = "yellow";
ctx.stroke();
}
setInterval(function(){
draw();
if(ope)
angle++;
else
angle--;
if(angle <= 1 || angle >= 30){
ope = (angle <= 1) ? true : false;
}
}, 6);
</script>
<script id="jsbin-source-javascript" type="text/javascript">var stage = document.createElement("canvas");
stage.style.backgroundColor = "black";
stage.style.width = "300";
stage.style.height = "300";
document.body.appendChild(stage);
var ctx = stage.getContext("2d");
var ope = false;
angle = 30;
function draw(){
ctx.beginPath();
ctx.arc(75,75,20, 0, Math.PI*2,true);
ctx.lineWidth = 41;
ctx.strokeStyle = "black";
ctx.stroke();
ctx.beginPath();
ctx.arc(75,75,20, (Math.PI/180)*angle, -(Math.PI/180)*angle);
ctx.lineWidth = 40;
ctx.strokeStyle = "yellow";
ctx.stroke();
}
setInterval(function(){
draw();
if(ope)
angle++;
else
angle--;
if(angle <= 1 || angle >= 30){
ope = (angle <= 1) ? true : false;
}
}, 6);</script></body>
</html>
var stage = document.createElement("canvas");
stage.style.backgroundColor = "black";
stage.style.width = "300";
stage.style.height = "300";
document.body.appendChild(stage);
var ctx = stage.getContext("2d");
var ope = false;
angle = 30;
function draw(){
ctx.beginPath();
ctx.arc(75,75,20, 0, Math.PI*2,true);
ctx.lineWidth = 41;
ctx.strokeStyle = "black";
ctx.stroke();
ctx.beginPath();
ctx.arc(75,75,20, (Math.PI/180)*angle, -(Math.PI/180)*angle);
ctx.lineWidth = 40;
ctx.strokeStyle = "yellow";
ctx.stroke();
}
setInterval(function(){
draw();
if(ope)
angle++;
else
angle--;
if(angle <= 1 || angle >= 30){
ope = (angle <= 1) ? true : false;
}
}, 6);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment