js实现canvas炫酷多彩旋转隧道动画效果代码

代码语言:html

所属分类:动画

代码描述:js实现canvas炫酷多彩旋转隧道动画效果代码

代码标签: 炫酷 多彩 旋转 隧道 动画 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<html>
<head>
    <meta charset="utf-8">


    <style type="text/css">
        body, html {
            background-color: #111;
            overflow: hidden;
            margin: 0 0;
        }
        #c {
            position: absolute;
            top: calc(50vh - 200px);
            left: calc(50vw - 200px);
        }
        #alpha {
            position: absolute;
            top: calc(50vh + 220px);
            left: calc(50vw - 50px);
            width: 100px;
            height: 40px;
            background-color: #000;
            border: none;
            font: 20px Verdana;
            color: white;
            text-shadow: 0 0 2px white;
            cursor: pointer;

            transition: .4s;
        }
        #alpha:focus {
            outline: none;
        }
        #alpha:hover {
            background-color: #555;
        }
        #overlay {
            position: absolute;
            width: 400px;
            height: 400px;
            top: calc(50vh - 200px);
            left: calc(50vw - 200px);
            background-image: radial-gradient(transparent 20%, #111 69%);
        }
    </style>

</head>
<body>

    <canvas id=c></canvas>
    <button id=alpha>alpha</button>
    <div id=overlay></div>


    <script>
        var w = c.width =
        h = c.height = 400,
        ctx = c.getContext('2d'),

        total = 50,
        particlesParRow = 10,
        minValue = 30,
        updatesBeforeStart = 500,
        repaintColor = 'rgba(0, 0, 0, .04)',
        templateColor = 'hsl(hue, 80%, 50%)',

        particles = [],
        colors = [],
        radiants = [],
        colorPart = 360/total,
        radiantPart = Math.PI*2/total,
        alphaValue = true;

        for (var i = 0; i < total; ++i) {

            var array = [];
            particles.push(array);
            colors.push(templateColor.replace('hue', colorPart * i));
            radiants.push(radiantPart * i);

            for (var j = 0; j < particlesParRow; ++j) {
                array.push(i * minVa.........完整代码请登录后点击上方下载按钮下载查看

网友评论0