Created
December 15, 2018 22:08
-
-
Save klaylton/3910f7c50e1de57a14ad089ed6dcab9b to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/yulamed
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
<!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> |
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 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