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 ...
随机推荐
- ios推送基于YII第三方组件的类库
<?php namespace common\extensions\push; use \CComponent; /** * @desc iphone推送的接口程序 */ class ApnsP ...
- angular2 select change 事件
刚开始这是啥?(wrong!!! change事件会在 选择option行为 之前执行prodDirId,是取不到选择后正确的id值的,取得是选择行为前prodDirId的值(有试过setTi ...
- android API文档查询---context、toast、SharedPreferences
/*查阅api ---context1.abstract AssetManager getAssets() Returns an AssetManager instance for the a ...
- 06_XML的写入_dom4j添加、删除、修改Xml文件内容
[工程截图] [person.xml]准备一个xml文件 <?xml version="1.0" encoding="UTF-8"?> <st ...
- HTML5 Video与Audio 视频与音频
---- 视频Video对象 - 指定视频播放地址 <video width="320" height="240" controls="cont ...
- 在Window IIS中安装运行node.js应用—你疯了吗
[原文发表地址]Installing and Running node.js applications within IIS on Windows - Are you mad? [原文发表时间]201 ...
- Linux中的磁盘
Linux的磁盘管理 (很重要请注意高能预警) 硬盘:几个盘片,双面,磁性颗粒, 处理速率不同步:借助于一个中间层 文件系统(FileSystem) 可以实现对磁盘行的文件进行读写 文 ...
- leetcode Permutations II 无重全排列
作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4051169.html 题目链接:leetcode Permutations II 无重全排 ...
- 小shell函数
whoport() { port=$1 echo "------ who occupied port: $port ----------" info=$(sudo lsof ...
- JS 立即执行的函数表达式(function)写法
1. 正确的写法 对于JavaScript 来说,括弧()里面不能包含语句,所以在这一点上,解析器在解析function关键字的时候,会将相应的代码解析成function表达式,而不是function ...