当前位置: 首页  >  下载站  >  js特效  >  CSS3特效  >  css3+HTML5 Canvas炫酷3D线条延伸动画特效

css3+HTML5 Canvas炫酷3D线条延伸动画特效

css3+HTML5 Canvas炫酷3D线条延伸动画特效

css3+HTML5 Canvas炫酷3D线条延伸动画特效
分类:   js特效 / CSS3特效 发布时间:  2018-01-19 访问量:  2056
下载量:  57
点击下载 预览效果
更多>

最新下载

jQuery企业留言表单联系代码

jQuery企业留言表单联系代码是一款简洁实用的企业留言表单和联系我们介绍页面代码。
112 2024-02-29

HTML5 MP3音乐盒播放特效

HTML5 MP3音乐盒播放特效是一款基于html5+css3制作可爱的音乐盒表情,点击开关按钮mp3音乐播放器。
108 2024-02-29

HTML5炫酷粒子动画导航菜单特效

HTML5炫酷粒子动画导航菜单特效是一款导航菜单采用鼠标悬停变色的特效。
136 2024-02-29

jQuery可视化表单拖拽编辑代码

jQuery可视化表单拖拽编辑代码是一款基于jQuery和bootstrap框架制作可视化表单。
97 2024-02-29

VUE.JS仿酷狗音乐播放器代码

VUE.JS仿酷狗音乐播放器代码是一款基于js跟css3实现的仿酷狗网页音乐播放器特效。
81 2024-02-29

经典html5推箱子小游戏

经典html5推箱子小游戏总共有100关,移动方式有上下左右按键。
127 2024-02-29
css3+HTML5 Canvas炫酷3D线条延伸动画特效
js代码

<script>
;(function() {
  'use strict';
  var c = document.getElementById('c');
  var ctx = c.getContext('2d');
  var w = c.width = window.innerWidth;
  var h = c.height = window.innerHeight;
  var cx = w / 2;
  var cy = h / 2;
  var fl = 1000;
  
  function prj(obj) {
    var cz = obj.z + fl;
    if(cz === 0) return;
    var scl = fl / cz;
    obj.p.x = cx + obj.x * scl;
    obj.p.y = cy + obj.y * scl;
    obj.s = scl;
  }
  
  var P = function(x, y, z) {
    this.x = x;
    this.y = y;
    this.z = z;
    this.s = 1;
    this.cl = 0;
    this.p = {
      x: 0,
      y: 0
    };
  };
  P.prototype = {
    constructor: P,
    update: function() {
      this.z -= 30;
    },
    render: function(ctx) {
      if(this.z <= -fl) return;
      ctx.save();
      ctx.translate(this.p.x, this.p.y);
      ctx.scale(this.s, this.s);
      ctx.fillStyle = 'hsla(' + this.cl + ', 100%, 50%, 0.5)';
      ctx.beginPath();
      ctx.arc(0, 0, 2, 0, Math.PI * 2);
      ctx.fill();
      ctx.restore();
    }
  };
  var M = function(x, y, z) {
    this.list = [];
    this.max = 100;
    this.x = x;
    this.y = y;
    this.z = z;
    this.s = 1;
    this.p = {
      x: 0,
      y: 0
    };
    this.ax = Math.random() * (Math.PI * 2);
    this.ay = Math.random() * (Math.PI * 2);
    this.rx = Math.random() * 100;
    this.ry = Math.random() * 100;
    this.cl = Math.random() * 360;
    this.cls = Math.random();
  };
  M.prototype = {
    constructor: M,
    update: function() {
      this.cl += this.cls;
      this.ax += Math.random() * 0.1 - 0.02;
      this.ay += Math.random() * 0.1 - 0.02;
      this.x = Math.cos(this.ax) * 100;
      this.y = Math.sin(this.ay) * 100;
      this.z += 10;
      if(this.z > fl) this.z = fl;
      
      if(this.list.length < this.max) {
        if(Math.random() * 100 < 50) {
          var pp = new P(this.x, this.y, this.z);
          pp.cl = this.cl;
          this.list.push(pp);        
        }
      } else {
        var pp = this.list.shift();
        pp.x = this.x;
        pp.y = this.y;
        pp.z = this.z;
        pp.cl = this.cl;
        this.list.push(pp);
      }
    },
    render: function(ctx) {
      if(this.z <= -fl) return;
      ctx.save();
      ctx.translate(this.p.x, this.p.y);
      ctx.fillStyle = 'green';
      ctx.beginPath();
      ctx.arc(0, 0, 2, 0, Math.PI * 2);
      ctx.fill();
      ctx.restore();
    }
  };
  
  function update(mv, list) {
    for(var i = 0; i < list.length; i++) {
      var p = list[i];
      p.update();
      prj(p);
      p.render(ctx);
    }
    
    for(var i = list.length-1; i >= 0; i--) {
      var p = list[i];
      if(p.z <= -fl) continue;
       if(i === list.length - 1) {
         ctx.lineWidth = Math.random();
         ctx.strokeStyle = 'hsl(' + mv.cl + ', 100%, 50%)';
         ctx.beginPath();
         ctx.moveTo(p.p.x, p.p.y);
       } else {
         ctx.lineTo(p.p.x, p.p.y);
       }
    }
    ctx.stroke();
  }
  
  var ms = [];

  for(var i = 0; i < 10; i++) {
    ms.push(new M(
      Math.random() * 400 - 200, 
      Math.random() * 400 - 200, 
      Math.random() * 400 - 200));
  }

  requestAnimationFrame(function loop() {
    requestAnimationFrame(loop);
    ctx.clearRect(0, 0, w, h);
    
    for(var i = 0; i < ms.length; i++) {
      var m = ms[i];
      m.update();
      prj(m);
      update(m, m.list);
    }
   
  });
})();
</script>
这是一款基于HTML5 Canvas绘制的炫酷3D线条延伸动画特效,多彩颜色变幻,非常漂亮! 

本站所有资源都是由网友投搞发布,或转载各大下载站,请自行检测软件的完整性!本站所有资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!如有侵权请联系我们删除下架,联系方式:admin@php.cn

相关推荐

css3+HTML5 Canvas炫酷3D线条延伸动画特效

css3+HTML5 Canvas炫酷3D线条延伸动画特效
CSS3特效
2018-01-19

H5+Canvas炫酷3D线条延伸动画特效

H5+Canvas炫酷3D线条延伸动画特效
html5特效
2018-05-28

HTML5 Canvas+WebGL酷炫3D噪音线条动画特效

一款HTML5 Canvas+WebGL酷炫3D噪音线条动画特效
html5特效
2023-04-18

html5 canvas炫酷线条动画特效

一款html5 canvas炫酷线条动画特效
html5特效
2023-04-18

html5 canvas螺旋点结合线条无限延伸背景动画特效

一款html5 canvas螺旋点结合线条无限延伸背景动画特效
html5特效
2023-01-30

酷炫黑色HTML5 3D线条凹凸人物头像动画特效

酷炫黑色HTML5 3D线条凹凸人物头像动画特效
html5特效
2018-05-26

酷CSS3+html5自行车线条描边动画特效

酷CSS3+html5自行车线条描边动画特效
CSS3特效
2018-06-02

html5 canvas全屏酷炫星光闪烁3D视差背景动画特效

一款html5 canvas全屏酷炫星光闪烁3D视差背景动画特效
html5特效
2023-01-11

热门下载

jQuery+Html5实现唯美表白动画代码

jQuery+Html5实现唯美表白动画代码,动画效果很棒,程序员表白必备!
其它特效
2017-02-14

情侣浪漫表白js特效代码

情侣浪漫表白js特效代码,这样的特效,可以用在婚纱摄影的网站上,也可以放在个人网站中,也还一个不错的特效,php中文网推荐下载!
其它特效
2017-02-08

炫酷的系统登录页

炫酷的系统登录页
jQuery特效
2019-12-30

H5熊猫弹跳小游戏源码

html5手机熊猫也疯狂小游戏源代码。游戏说明:长按屏幕调整熊猫弹簧的强度,跳到石柱上。掉到河里游戏结束。
html5特效
2019-08-22

H5 3D滚球游戏源码

html5酷炫3D彩球滚动手机游戏代码下载。游戏介绍:一个彩色圆球滚动,通过鼠标或手机触屏拖动来控制彩球的运行当前线路轨迹。这是一款简单易操作的手机小游戏源码。
html5特效
2019-08-26

HTML5 canvas射击鸭子小游戏

HTML5 canvas射击鸭子小游戏
html5特效
2017-11-24

HTML5+three实现3D酷炫拼魔方游戏特性

html5基于three.js制作3D拼魔方小游戏,双击开始游戏,看你来多少时间内能拼成魔方游戏。单击鼠标拖动可以3D查看魔方位面。
html5特效
2019-04-04

简单js恋爱表白神器

简单原生js恋爱表白神器
其它特效
2017-02-14
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

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