html5 spring demo
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Follow Mouse</title>
<script type="text/javascript" src="utils.js"></script>
<script type="text/javascript" src="ball.js"></script>
<style type="text/css">
body{background-color: silver;}
#canvas{background-color: white;}
</style>
</head>
<body>
<canvas id="canvas" width="400" height="400"></canvas>
<textarea name="" id="log" cols="30" rows="10"></textarea>
<script type="text/javascript">
window.onload=function(){
var canvas=document.getElementById("canvas"),
context=canvas.getContext("2d"),
mouse=utils.captureMouse(canvas),
ball=new Ball(),
spring=0.03,
friction=0.9,
gravity=2,
vx=0,
vy=0;
(function drawFrame(){
window.requestAnimationFrame(drawFrame,canvas);
context.clearRect(0,0,canvas.width,canvas.height); var dx=mouse.x-ball.x,
dy=mouse.y-ball.y,
ax=dx*spring,
ay=dy*spring;
vx+=ax;
vy+=ay;
vy+=gravity;
vx*=friction;
vy*=friction;
ball.x+=vx;
ball.y+=vy;
context.beginPath();
context.moveTo(ball.x,ball.y);
context.lineTo(mouse.x,mouse.y);
context.stroke();
ball.draw(context); }())
}
</script>
</body>
</html>
utils.js 文件 https://gist.github.com/King-fly/6034511/raw/2e28359afdfb45800948f0e6bd31aa958ba7f5cb/html5+utilsball.js 文件 https://gist.github.com/King-fly/6034525/raw/4664959f6e33196b9b4520136cc67573e07c8282/ball.js
html5 spring demo的更多相关文章
- HTML5 LocalStorage Demo
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> ...
- 手写Spring+demo+思路
我在学习Spring的时候,感觉Spring是很难的,通过学习后,发现Spring没有那么难,只有你去学习了,你才会发现,你才会进步 1.手写Spring思路: 分为配置.初始化.运行三个阶段如下图 ...
- 第一个Spring demo
参考Spring3.x企业实战 1.新建web工程chapter5,导入jar包.注意:cglib和commons-dbcp这两个包 2.设计数据库 t_login_log表结构(存放日志信息),主键 ...
- Html5 Geolocation demo
<!DOCTYPE html> <head> <meta charset="utf-8"> <title>HTML5 Geoloca ...
- spring demo
参考: https://www.tutorialspoint.com/spring/spring_applicationcontext_container.htm
- spring boot 登录注册 demo (一)
Welcome to Spring Boot 代码结构 src/main/java 下 controller层,路由功能dao层,数据库的访问domain,bean的存放service,业务层appl ...
- 【Java】 Spring依赖注入小试牛刀:编写第一个Spring ApplicationContext Demo
0 Spring的依赖注入大致是这样工作的: 将对象如何构造(ID是什么?是什么类型?给属性设置什么值?给构造函数传入什么值?)写入外部XML文件里.在调用者需要调用某个类时,不自行构造该类的对象, ...
- 【spring boot】SpringBoot初学(2) - properties配置和读取
前言 只是简单的properties配置学习,修改部分"约定"改为自定义"配置".真正使用和遇到问题是在细看. 一.主要 核心只是demo中的: @Proper ...
- Spring Boot(5)一个极简且完整的后台框架
https://blog.csdn.net/daleiwang/article/details/75007588 Spring Boot(5)一个极简且完整的后台框架 2017年07月12日 11:3 ...
随机推荐
- 查看帮助文档的一些方法:help,dir,type,func_global等
help与dir与type:在使用python来编写代码时,会经常使用python自带函数或模块,一些不常用的函数或是模块的用途不是很清楚,这时候就需要用到help函数来查看帮助.这里要注意下,hel ...
- GetDeviceCaps() 参数
GetDeviceCaps 检测设备指定信息 参数: #define DRIVERVERSION 0 /* 设备驱动版本 */ #define TECHNOLOGY 2 /* Device class ...
- 03链栈_LinkStack--(栈与队列)
#include "stdio.h" #include "stdlib.h" #include "io.h" #include " ...
- N个数随机相加得出固定值的排列组合
static double[] iArr = new double[10] { 1,2,3,4,5,6,7,8,9,10 }; static Stack<double> stack = n ...
- 【原创】开机出现grub rescue,修复办法
出现这种问题 一般在于进行了磁盘分区(GHOST备份时也会造成)导致grub引导文件找不到.我们只要让它找到引导文件就好了. 此时屏幕上提示grub resume> 我们先输入set看下现在g ...
- HaProxy+keepalived实现负载均衡
HAProxy提供高可用性.负载均衡以及基于TCP和HTTP应用的代理,支持虚拟主机,它是免费.快速并且可靠的一种解决方案.HAProxy特别适用于那些负载特大的web站点,这些站点通常又需要会话保持 ...
- Qt-获取主机网络信息之QHostInfo
Qt中提供了几个用于获取主机网络信息的类,包括QHostInfo.QHostAddress.QNetworkInterface以及QNetworkAddress.在本节中,我将在这里总结QHostIn ...
- Cassandra1.2文档学习(7)—— 规划集群部署
数据参考:http://www.datastax.com/documentation/cassandra/1.2/webhelp/index.html#cassandra/architecture/a ...
- ACE 6.2.0 RHEL6_Linux 编译
第一步. 设置环境变量 export ACE_ROOT=$HOME/ace/ACE_wrappersexport LD_LIBRARY_PATH=$ACE_ROOT/ace:$ACE_ROOT/lib ...
- jquery点击其他地方隐藏div层的实现程序
js代码 $(document).ready(function() { //语言头部的点击事件,显示语言列表 $(".language_selected").click(funct ...