Jquery implements dynamic drawing of circles

  • 2020-03-30 04:30:03
  • OfStack

Today, I found a good knowledge in the process of writing plug-ins. I made a little example myself.


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title> Headless document </title>
<!-- The script to load -->
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(e) {
    var a = 200, b = 200, r = 90, times = 0;
    setInterval(function flutter() {
        times += 0.1;
        var hudu = (2*Math.PI / 360) * 6 * times;
        var X = a + Math.sin(hudu) * r;
        var Y = b - Math.cos(hudu) * r    //  Notice the minus sign here, because we're going to get Y relative to 0,0. < br / >         //$(".sky_text").css({"left":X+"px","top":Y+"px"});
        $("body").append('<div style="position:absolute; left:'+X+'px; top:'+Y+'px; width:1px; height:1px; background:#00F;"></div>');
        if(times == 60){
            return;
        }
    }, 2);
});
</script>
<style type="text/css">
body,html{ padding:0; margin:0;}
</style>
</head>
<body>
<div style="position:absolute; left:198px; top:198px; width:4px; height:4px; background:#F00;"></div>
</body>
</html>


Related articles: