Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
body, html { background-color: #000; color: #fff; width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden; } canvas { position:absolute; top:0; left:0 }
JavaScript
(function () { var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) { window.setTimeout(callback, 1000 / 60); }; window.requestAnimationFrame = requestAnimationFrame; })(); var canvas = document.getElementById("canvas"), ctx = canvas.getContext("2d"); ctx.lineWidth = 4; // Color stuff not real important just fluff var cycle = 0, colors = { r: 0, g: 170, b: 0 }; function colorCycle(inc) { cycle += inc; if (cycle > 100) { cycle = 0; } colors.r = ~~ (Math.sin(.3 * cycle + 0) * 127 + 128); colors.g = ~~ (Math.sin(.3 * cycle + 2) * 127 + 128); colors.b = ~~ (Math.sin(.3 * cycle + 4) * 127 + 128); } // Sections and points function Point(x, y, z, size) { this.x = x; this.y = y; this.z = z; this.xpos = 0; this.ypos = 0; this.size = 5; rotateY(this,angle+=0.1); } function Section(x, y, z, width) { this.x = x; this.y = y; this.z = z; this.width = width; this.points = []; this.points.push(new Point(this.x - this.width / 2, this.y, this.z, 20)); this.points.push(new Point(this.x + this.width / 2, this.y, this.z, 20)); this.render = function (angleX, angleY) { ctx.beginPath(); for (var p = 0; p < this.points.length; p++) { var point = this.points[p]; rotateX(point, angleX); rotateY(point, angleY); doPerspective(point); ctx.arc(point.xpos, point.ypos, point.size, 0, Math.PI * 2, true); if (p == 0) { ctx.moveTo(this.points[0].xpos, this.points[0].ypos); } else { ctx.lineTo(point.xpos, point.ypos); } } ctx.closePath(); ctx.stroke(); ctx.fill(); } } // 3d Functions for rotation and perspective function rotateX(point, angleX) { var cosX = Math.cos(angleX), sinX = Math.sin(angleX), y1 = point.y * cosX - point.z * sinX, z1 = point.z * cosX + point.y * sinX; point.y = y1; point.z = z1; } function rotateY(point, angleY) { var cosY = Math.cos(angleY), sinY = Math.sin(angleY), x1 = point.x * cosY - point.z * sinY, z1 = point.z * cosY + point.x * sinY; point.x = x1; point.z = z1; } function doPerspective(point) { if (point.z > -fl) { var scale = fl / (fl + point.z); point.size = scale * 5; point.xpos = vpX + point.x * scale; point.ypos = vpY + point.y * scale; } } // Init code var sections = [], numSections = 50, fl = 250, vpX, vpY, angle = 0; // make some sections for (var i = 0; i < numSections; i++) { sections.push(new Section(0, -250 + (i * 10), 0, 50)); } function render() { ctx.clearRect(0, 0, canvas.width, canvas.height); colorCycle(0.1); ctx.fillStyle = "rgb(" + colors.r + "," + colors.g + "," + colors.b + ")"; ctx.strokeStyle = "rgb(" + colors.r + "," + colors.g + "," + colors.b + ")"; for (var i = 0; i < sections.length; i++) { sections[i].render(0, 0.03); } requestAnimationFrame(render); } setTimeout(function () { canvas.width = window.innerWidth, canvas.height = document.body.offsetHeight; vpX = canvas.width / 2; vpY = canvas.height / 2; render(); },110);
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>dna螺旋动画-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号