zoukankan      html  css  js  c++  java
  • html5 js canvas中画星星的函数

    function drawStar(cxt, x, y, outerR, innerR, rot) {
                 cxt.beginPath();
                 for (var i = 0; i < 5; i++) {
                     cxt.lineTo(Math.cos((18+i*72-rot)/180*Math.PI)*outerR+x,
                     -Math.sin((18+i*72-rot)/180*Math.PI)*outerR+y);
                     cxt.lineTo(Math.cos((54 + i * 72 - rot) / 180 * Math.PI) * innerR + x,
                         -Math.sin((54 + i * 72 - rot) / 180 * Math.PI) * innerR + y);
                 }
                 cxt.closePath();
    
                 cxt.fillStyle = "#fb3";
                 cxt.strokeStyle = "#fd5";
                 cxt.lineWidth = 3;
                 cxt.lineJoin = "rount";
    
                 cxt.fill();
                 cxt.stroke();
             }
    function draw() {
                 for (var i = 0; i < 200; i++) {
                     var r = Math.random() * 10 + 10;
                     var x = Math.random() * cvs.width;
                     var y = Math.random() * cvs.height;
                     var a = Math.random() * 360;
                     drawStar(context, x, y, r, r / 2.0, a);
                 }
             }
  • 相关阅读:
    information_schema
    面包屑路径导航
    mysql5.7.26安装
    菜单权限作为父权限
    权限控制到按钮
    二级菜单
    留言板和jq轮播图
    M商城
    表单
    w3c
  • 原文地址:https://www.cnblogs.com/lunawzh/p/5168044.html
Copyright © 2011-2022 走看看