欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

旋转的辐射Logo

程序员文章站 2022-07-02 18:50:27
var canvas = document.getelementbyid("mycanvas");  var context = canvas.getcontext(&...

var canvas = document.getelementbyid("mycanvas"); 
var context = canvas.getcontext("2d"); 
var startp = [0 , 0.67 , 1.34 ]; 
var endp = [0.3 , 0.97 , 1.64]; 
var n = 0.01; 
var animate; 
window.onload = initpage; 
 
function initpage() { 
    var speed = document.getelementsbytagname("select")[0].value; 
    window.clearinterval(animate); 
    animate = setinterval("show()",speed); 

 
function show() { 
    context.clearrect(0,0,500,500); 
    for(var i = 0 ; i<3 ; i++) { 
    startp[i] += n; 
    endp[i] += n; 
    if(startp[i] == 2) { 
        startp[i] = 0; 
    } 
    if(endp[i] == 2) { 
        endp[i] = 0; 
    } 
    } 
    context.beginpath(); 
    context.rect(0,0,500,500); 
    context.linewidth = 1; 
    context.fillstyle = "#f2ca07"; 
    context.fill(); 
    context.stroke(); 
 
    context.beginpath(); 
    context.arc(250, 250, 10, 0, 2 * math.pi, false); 
    context.linewidth = 1; 
    context.fillstyle = "#333"; 
    context.fill(); 
    context.stroke(); 
 
    context.beginpath(); 
    context.arc(250, 250, 100, startp[0] * math.pi, endp[0] * math.pi, false); 
    context.linewidth = 160; 
    context.strokestyle = "#333"; 
    context.stroke(); 
 
    context.beginpath(); 
    context.arc(250, 250, 100, startp[1] * math.pi, endp[1] * math.pi, false); 
    context.linewidth = 160; 
    context.strokestyle = "#333"; 
    context.stroke(); 
 
    context.beginpath(); 
    context.arc(250, 250, 100, startp[2] * math.pi, endp[2] * math.pi, false); 
    context.linewidth = 160; 
    context.strokestyle = "#333"; 
    context.stroke(); 


demo


摘自 简生的代码备忘录