2017.12.7
来源:互联网 发布:淘宝联盟手机返利 编辑:程序博客网 时间:2024/06/06 00:11
canvas demo
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>泡泡特效</title>
<style>
*{
margin:0;
padding:0;
}
canvas{
display:block;
background-color:#000000;
}
</style>
</head>
<body>
<canvas id="Bubble"></canvas>
<script>
var canvas = document.getElementById("Bubble");
canvas.width = innerWidth;
canvas.height = innerHeight;
window.onresize = function(){
canvas.width = innerWidth;
canvas.height = innerHeight;
}
var ctx = canvas.getContext("2d");
setInterval("runCircle()",1000/2);
function runCircle(){
ctx.clearRect(0,0,innerWidth,innerHeight);
var count = 0;
do{
randomCircle();
count++;
}while(count<200);
}
function randomCircle(){
var r = Math.floor(Math.random()*255);
r = r.toString(16);
var g = Math.floor(Math.random()*255);
g = g.toString(16);
var b = Math.floor(Math.random()*255);
b = b.toString(16);
var rgb = "#"+r+g+b;
var x = Math.floor(Math.random()*innerWidth);
var y = Math.floor(Math.random()*innerHeight);
var radius = Math.floor(Math.random()*20)
ctx.fillStyle = rgb;
ctx.beginPath();
ctx.arc(x,y,radius,0,2*Math.PI,true);
ctx.closePath();
ctx.fill();
}
</script>
</body>
</html>
阅读全文
0 0
- 2017.12.7
- 2017.12.7
- 2017.12.7
- 2017.12.7
- 2017.12.7
- 周中记录--2017.12.7
- 2017.12.7 第一天-维修列表
- 2017.12.7学习前端的总结
- 2017.12.7第十五周周中总结
- [LeetCode-Algorithms-75] "Sort Colors" (2017.12.7-WEEK14)
- [LeetCode-Algorithms-537] "Complex Number Multiplication" (2017.12.7-WEEK14)
- 2017.12.01
- 2017.12.3
- 2017.12.3
- 2017.12.4
- 2017.12.5
- 2017.12.6
- 2017.12.6
- 遇到了ImportError: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory
- Java面试题全集(上)
- opencv(四)对图像处理
- windows7下基于Anaconda安装TensorFlow
- Gradle的高级技巧
- 2017.12.7
- QT控件大全 二十一 QPush
- 线程的初步理解,生命周期,实现方法,Thread类,Runnable接口,Callable接口线程池
- Scala学习笔记之 --- Array、ArrayBuffer以及遍历数组(1)
- ajax之$.post
- VS error LNK2001:无法解析的外部符号 xxx
- Arduino电路图教程
- java学习笔记-this关键字
- OS学习笔记——处理器调度1