javascript - 一个页面动画的问题?
伊谢尔伦
伊谢尔伦 2017-04-11 09:23:53
[JavaScript讨论组]

http://cheers.oneplus.cn/acti...
页面链接如上。
很想知道背景的波浪线条动画是怎么做出来?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回复(4)
伊谢尔伦

楼上的,或许搞错了哦。

它们的背景线条动画是通过两个个canvas的动画拼接起来的。

再补充一点,看起来就是在不断跑sin和sos函数轨迹

function canvasBezier(a, b) {
    function c() {
        f.clearRect(0, 0, cwidth, cheight);
        for (var a = 3; a > 0; a--) {
            d[a - 1] += .5 * a;
            var c = (d[a - 1] + 120 * a) * Math.PI / 180;
            if (b)
                var e = Math.cos(c) * cheight * .09
                  , g = Math.sin(c) * cheight * .06;
            else
                var e = Math.sin(c) * cheight * .06
                  , g = Math.cos(c) * cheight * .09;
            f.setTransform(1, 0, 0, 1, 0, 0),
            f.strokeStyle = "rgba(" + bezierColor + (.2 * Math.cos(c) + .5) + ")",
            f.beginPath(),
            f.moveTo(0, .5 * cheight + e),
            f.bezierCurveTo(cwidth / 2, .5 * cheight + 2.5 * e, cwidth / 2, .5 * cheight + 2 * g, cwidth, .5 * cheight + g),
            f.stroke()
        }
    }
    if (!Modernizr.canvas)
        return !1;
    var d = [0, 0, 0]
      , e = document.getElementById(a)
      , f = e.getContext("2d");
    cwidth = $(window).width() >= 1130 ? $(window).width() : 1130,
    cheight = $(window).height(),
    e.width = cwidth,
    e.height = cheight,
    f.lineWidth = .5,
    e.timer = setInterval(c, 30),
    $(window).resize(function() {
        clearInterval(e.timer),
        cwidth = $(window).width() >= 1130 ? $(window).width() : 1130,
        cheight = $(window).height(),
        e.width = cwidth,
        e.height = cheight,
        f.lineWidth = 1,
        e.timer = setInterval(c, 30)
    })
}
伊谢尔伦

看下源码呗,应该是用canvas吧

PHP中文网

canvas,你可以找找那种扒代码的工具,看能不能扒下来

PHPz

很遗憾,是张图片
http://statics.oneplus.cn/pro...

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号