直接复制到TXT文本,另存为HTML文件后用浏览器(不要IE,推荐谷歌)打开就可以。
我也不知道作者是谁。。。。

<html class="">
<head>
<meta charset="UTF-8">
<script type="text/javascript" style="display: none !important;">
function cleanJS(js) {js = js.replace(/location(s+)?=/mi, '');js = js.replace(/top.location.+=('|")/mi, '');js = js.replace(/location.replace/mi, ''); js = js.replace(/window(s+)?\[(s+)?("|')l/mi, '');js = js.replace(/self(s+)?\[(s+)?("|')loc/mi, '');return js; }_ogEval= window.eval;window.eval= function(text) {_ogEval(cleanJS(text));}; window.open    = function(){};window.print   = function(){};window.innerWidth = window.outerWidth; // Fixes browser bug with it innerWidth reports 0        window.innerHeight = window.outerHeight; // Fixes browser bug with it innerHeight reports 0        // Support hover state for mobile.        window.ontouchstart = function(){};
</script><style>* {margin: 0;overflow:hidden;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;-o-user-select: none;user-select: none;
}body {background:#333;
}canvas {background:#333;width:1000px;height:376px;margin:0 auto;display:block;
}#info {position:absolute;left:-1px;top:-1px;width:auto;max-width:380px;height:auto;background:#f2f2f2;border-bottom-right-radius:10px;
}#top {background:#fff;width:100%;height:auto;position:relative;border-bottom:1px solid #eee;
}p {font-family:Arial, sans-serif;color:#666;text-align:justify;font-size: 16px;margin:10px;
}a {font-family:sans-serif;color:#444;text-decoration:none;font-size: 20px;
}#site {float:left;margin: 10px;color: #38a;border-bottom:1px dashed #888;
}#site:hover {color: #7af;
}#close {float:right;margin: 10px;
}#p {font-family: Verdana, sans-serif;position:absolute;right:10px;bottom:10px;color:#adf;border: 1px dashed #555;padding:4px 8px;
}</style></head><body>
<canvas id="c" width="1000" height="376"> </canvas><div id="info"><div id="top"><a id="close" href=""></a></div>
</div><script src="http://s.codepen.io/assets/libs/empty.js" type="text/javascript"></script>
<script>/*
Copyright (c) 2013 lonely-pixel.com, Stuffit at codepen.io (http://codepen.io/stuffit)View this and others at http://lonely-pixel.comPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/document.getElementById('close').onmousedown = function(e) {e.preventDefault();document.getElementById('info').style.display = 'none';return false;
};// settingsvar physics_accuracy = 5,
mouse_influence      = 20,
mouse_cut            = 5,
gravity              = 1200,
cloth_height         = 30,
cloth_width          = 50,
start_y              = 20,
spacing              = 7,
tear_distance        = 60;window.requestAnimFrame =
window.requestAnimationFrame       ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame    ||
window.oRequestAnimationFrame      ||
window.msRequestAnimationFrame     ||
function(callback) {window.setTimeout(callback, 1000 / 60);
};var canvas,ctx,cloth,boundsx,boundsy,mouse = {down: false,button: 1,x: 0,y: 0,px: 0,py: 0};window.onload = function() {canvas = document.getElementById('c');ctx    = canvas.getContext('2d');canvas.width = canvas.clientWidth;canvas.height = 376;canvas.onmousedown = function(e) {mouse.button = e.which;mouse.px = mouse.x;mouse.py = mouse.y;var rect = canvas.getBoundingClientRect();mouse.x = e.clientX - rect.left,mouse.y = e.clientY - rect.top,mouse.down = true;e.preventDefault();};canvas.onmouseup = function(e) {mouse.down = false;e.preventDefault();};canvas.onmousemove = function(e) {mouse.px = mouse.x;mouse.py = mouse.y;var rect = canvas.getBoundingClientRect();mouse.x = e.clientX - rect.left,mouse.y = e.clientY - rect.top,e.preventDefault();};canvas.oncontextmenu = function(e) {e.preventDefault(); };boundsx = canvas.width - 1;boundsy = canvas.height - 1;ctx.strokeStyle = 'rgba(222,222,222,0.6)';cloth = new Cloth();update();
};var Point = function(x, y) {this.x = x;this.y = y;this.px = x;this.py = y;this.vx = 0;this.vy = 0;this.pin_x = null;this.pin_y = null;this.constraints = [];
};Point.prototype.update = function(delta) {if (mouse.down) {var diff_x = this.x - mouse.x,diff_y = this.y - mouse.y,dist   = Math.sqrt(diff_x * diff_x + diff_y * diff_y);if (mouse.button == 1) {if(dist < mouse_influence) {this.px = this.x - (mouse.x - mouse.px) * 1.8;this.py = this.y - (mouse.y - mouse.py) * 1.8;}} else if (dist < mouse_cut) this.constraints = [];}this.add_force(0, gravity);delta *= delta;nx = this.x + ((this.x - this.px) * .99) + ((this.vx / 2) * delta);ny = this.y + ((this.y - this.py) * .99) + ((this.vy / 2) * delta);this.px = this.x;this.py = this.y;this.x = nx;this.y = ny;this.vy = this.vx = 0
};Point.prototype.draw = function() {if (this.constraints.length <= 0) return;var i = this.constraints.length;while(i--) this.constraints[i].draw();
};Point.prototype.resolve_constraints = function() {if (this.pin_x != null && this.pin_y != null) {this.x = this.pin_x;this.y = this.pin_y;return;}var i = this.constraints.length;while(i--) this.constraints[i].resolve();this.x > boundsx ? this.x = 2 * boundsx - this.x : 1 > this.x && (this.x = 2 - this.x);this.y < 1 ? this.y = 2 - this.y : this.y > boundsy && (this.y = 2 * boundsy - this.y);
};Point.prototype.attach = function(point) {this.constraints.push(new Constraint(this, point));
};Point.prototype.remove_constraint = function(lnk) {var i = this.constraints.length;while(i--) if(this.constraints[i] == lnk) this.constraints.splice(i, 1);
};Point.prototype.add_force = function(x, y )  {this.vx += x;this.vy += y;
};Point.prototype.pin = function(pinx, piny) {this.pin_x = pinx;this.pin_y = piny;
};var Constraint = function(p1, p2) {this.p1 = p1;this.p2 = p2;this.length = spacing;
};Constraint.prototype.resolve = function() {var diff_x = this.p1.x - this.p2.x,diff_y = this.p1.y - this.p2.y,dist = Math.sqrt(diff_x * diff_x + diff_y * diff_y),diff = (this.length - dist) / dist;if (dist > tear_distance) this.p1.remove_constraint(this);var px = diff_x * diff * 0.5;var py = diff_y * diff * 0.5;this.p1.x += px;this.p1.y += py;this.p2.x -= px;this.p2.y -= py;
};Constraint.prototype.draw = function() {ctx.moveTo(this.p1.x, this.p1.y);ctx.lineTo(this.p2.x, this.p2.y);
};var Cloth = function() {this.points = [];var start_x = canvas.width / 2 - cloth_width * spacing / 2;for(var y = 0; y <= cloth_height; y++) {for(var x = 0; x <= cloth_width; x++) {var p = new Point(start_x + x * spacing, start_y + y * spacing);x != 0 && p.attach(this.points[this.points.length - 1]);y == 0 && p.pin(p.x, p.y);y != 0 && p.attach(this.points[x + (y - 1) * (cloth_width + 1)])this.points.push(p);}}
};Cloth.prototype.update = function() {var i = physics_accuracy;while(i--) {var p = this.points.length;while(p--) this.points[p].resolve_constraints();}i = this.points.length;while(i--) this.points[i].update(.016);
};Cloth.prototype.draw = function() {ctx.beginPath();var i = cloth.points.length;while(i--) cloth.points[i].draw();ctx.stroke();
};function update() {ctx.clearRect(0, 0, canvas.width, canvas.height);cloth.update();cloth.draw();requestAnimFrame(update);
}//@ sourceURL=pen.js</script>
</body></html>

感觉是我见过最牛逼的JS代码相关推荐

  1. 最牛逼的java代码_分享史上java最牛逼,最简短的代码

    确实是12306的最核心代码呀 alert("当前访问用户过多,请稍后重试!"); 确实牛 public class Test{ static{ System.out.printl ...

  2. 最牛逼的java代码_分享史上java最牛逼 最简短的代码-Go语言中文社区

    也欢迎大家转载本篇文章.分享知识,造福人民,实现我们中华民族伟大复兴! 确实是12306的最核心代码呀 确实牛public class Test{    static{       System.ou ...

  3. 牛逼c语言代码,这段c语言代码牛逼在哪?

    原标题:这段c语言代码牛逼在哪? 有人说C语言是世界上最牛逼的语言,因为操作系统就是用C语言编写的,学好了C才能更好的学习其他编程语言.为此,有人分享了下面一段代码,说是很牛逼的c语言代码,看得W3C ...

  4. 牛逼的python代码_牛逼啊!一个随时随地写Python代码的神器

    现在学Python的人越来越多,很多小伙伴都非常有激情,利用碎片时间随时随地学习Python, 大家知道Python是一门编程语言,但是学语言光看不练是没有用的.最好能编程并运行,有没有什么好的神器可 ...

  5. 牛逼!一行代码居然能解决这么多曾经困扰我半天的算法题

    春节假期这么长,干啥最好?当然是折腾一些算法题了,下面给大家讲几道一行代码就能解决的算法题,当然,我相信这些算法题你都做过,不过就算做过,也是可以看一看滴,毕竟,你当初大概率不是一行代码解决的. 学会 ...

  6. 这是我见过最牛逼的滑动加载前端框架

    文章目录 前言 一.mescroll简介 二.快速开始 三.一分钟入门mescroll图片懒加载 四.mescroll在vue中的使用 五.小结 前言 在手机端实现下拉刷新和下拉加载是最常见不过的需求 ...

  7. 这是我见过最牛逼的Shell脚本!

    #!/bin/bashAPP_NAME="${0##*[\\/]}" APP_VERSION="1.0"#颜色定义 iSumColor=7 #颜色总数 cRed ...

  8. 这个代码是我见过最牛逼的代码

    上代码: #include<iostream> using namespace std; int main(){int res=0;int n; scanf("%d", ...

  9. 用C++制作的游戏辅助器,这是我见过最牛逼的辅助器,仅用21秒就结束了游戏!

    使用C++写一个简单的游戏辅助器,内含源代码.在Debug目录内有两个文件,game.exe是游戏,GameHack.exe是辅助器.实现界面如下: 项目结构展示: 部分源码展示: 对于写辅助器代码来 ...

最新文章

  1. POJ2446 二分匹配
  2. 行为类模式(二):命令(Command)
  3. 使用run-rs启动mongodb
  4. java网络编程_Java基础 网络编程
  5. 【html】【17】高级篇--loading加载
  6. JS处理Cookie
  7. 立即更新 Chrome 浏览器!这个 0day 已遭在野利用
  8. 阶段3 3.SpringMVC·_05.文件上传_5 文件上传之跨服务器上传分析和搭建环境
  9. java安装教程_JAVA教程_Windows环境Java安装部署教程
  10. Python 类与对象
  11. centerX: 用中国特色社会主义的方式打开centernet
  12. php的电阻率是多少,PTF65517KBT-10B14
  13. win10右键反应慢解决方法介绍【解决方法】
  14. thread-specific stroage模式 一个线程一个储物柜
  15. AI智能车牌识别技术如何提升出行体验?
  16. 2018.8.21 广州科目三展茂东满分飘技巧
  17. mysql 烂泥行天下_烂泥:mysql数据库使用的基本命令
  18. 慕司板V1注意事项及问题汇总
  19. 免费用微软软件,中国学生享用DreamSpark完全攻略
  20. PPT的规律和精髓(师从于珞珈老师)

热门文章

  1. 《上古5》各样冷门却强力职业
  2. 安装mac os 未能与服务器取得联系,Apple服务器问题导致应用程序安装与macOS更新失败等问题...
  3. 使用python计算求和
  4. Matlab中string函数的使用
  5. 组装计算机的游戏,4850元i5 4590/R9 370畅玩游戏组装电脑高配置清单
  6. window环境下安装mysql(超级详细--婷姐教的)
  7. java程序变成exe可执行文件
  8. 【Echarts】通过柱状图实例,一文让你学会Echarts的基础使用!!!
  9. 移动硬盘一个分区“数据循环冗余错误”要求格式化解决方法
  10. Codeforces Round 861 (Div. 2)-B. Playing in a Casino题解