<!DOCTYPE html>
<html>

<head>
    <title>ゆき</title>
</head>
<style type="text/css" media="screen">
* {
    padding: 0px;
    border: 0px;
    margin: 0px;
}

#c {
    background-color: black;
}
</style>

<body>
    <canvas id="c"></canvas>
</body>
<script type="text/javascript">
var c = document.getElementById("c"),
    ctx = c.getContext("2d");
var width = c.width = innerWidth;
var height = c.height = innerHeight;
var store = [];
var lin = 0;

for (var i = 0; i < height; i++) {
    store.push({
        x: Math.floor(Math.random() * width),
        y: lin
    });
    lin++;
}

function draw() {
    ctx.clearRect(0, 0, c.width, c.height);
    for (var i = 0; i < height; i++) {
        ctx.beginPath();
        ctx.fillRect(store[i].x, store[i].y, 1, 1);
        ctx.fillStyle = "#ffffff";
        ctx.stroke();
        store[i].y += 1;
        if (store[i].y > c.height)
            store[i].y = 0;
        if (Math.floor(Math.random() > 0.5)) {
            store[i].x += Math.random() * 0.5;
        } else {
            store[i].x -= Math.random() * 0.5;
        }

    }
    window.requestAnimationFrame(draw);
}

draw();
</script>

</html>
<!DOCTYPE html>
<html>
<head>
	<title>このひかり</title>
</head>
<body>
<canvas id="c"></canvas>
</body>
<script type="text/javascript">

	var c = document.getElementById("c"),
	ctx = c.getContext("2d");

	c.width = innerWidth;
	c.height = innerHeight;
	var name =['J','o','k','i','n','g']
	var lines = [],
			maxSpeed = 5,
			spacing = 5,
			xSpacing = 0,
			n = innerWidth / spacing,
			colors = ["#3B8686", "#79BD9A", "#A8DBA8", "#0B486B"];

	for (i = 0; i < n; i++){
		xSpacing += spacing;
		lines.push({
			x: xSpacing,
			y: Math.round(Math.random()*c.height),
			width: 7,
			height: Math.round(Math.random()*(innerHeight/10)),
			speed: Math.random()*maxSpeed + 1,
			color: colors[Math.floor(Math.random() * colors.length)]
		});
	}

	function draw(){
		var i;
		ctx.clearRect(0,0,c.width,c.height);

		for (i = 0; i < n; i++){
			ctx.fillStyle = lines[i].color;
			ctx.font="20px Georgia";
			lines[i].y += lines[i].speed;
			test(i);
			ctx.textAlign="center";
			if (lines[i].y > c.height)
				lines[i].y = 0 - lines[i].height;
		}

		requestAnimationFrame(draw);

	}
	var test = (i)=>{
		ctx.fillText(name[Math.floor(Math.random() * name.length)],lines[i].x, lines[i].y);
	}
	draw();

</script>
</html>

Canvas Demo的更多相关文章

  1. canvas写的一个小时钟demo

    <!DOCTYPE html> <html> <head> <title>HTML5 Canvas Demo of clock</title> ...

  2. 在canvas中使用html元素

    让div悬浮于canvas之上   使用z-index控制层及顺序 慕课网canvas demo <div id="canvas-wrapper"> <canva ...

  3. canvas案例——画时钟

    基本思路,先画一个200半径的圆 ctx.arc(250,250,200,0,2*Math.PI); 然后再画时分刻度,可以先利用translate变化坐标到圆的中心点,然后再通过rotate旋转 / ...

  4. HTML5 之Canvas绘制太阳系

    <!DOCTYPE html> <html> <head> <title>HTML5_Canvas_SolarSystem</title> ...

  5. html5——canvas画直线

    <html> <head> <title>canvas demo</title> </head> <body> <canv ...

  6. HTML5 Canvas绘文本动画(使用CSS自定义字体)

    一.HTML代码: <!DOCTYPE html> <html> <head> <title>Matrix Text - HTML5 Canvas De ...

  7. 使用 HTML5 canvas 绘制精美的图形

    HTML5 是一个新兴标准,它正在以越来越快的速度替代久经考验的 HTML4.HTML5 是一个 W3C “工作草案” — 意味着它仍然处于开发阶段 — 它包含丰富的元素和属性,它们都支持现行的 HT ...

  8. HTML5 canvas 绘制精美的图形

    HTML5 是一个新兴标准,它正在以越来越快的速度替代久经考验的 HTML4.HTML5 是一个 W3C “工作草案” — 意味着它仍然处于开发阶段 — 它包含丰富的元素和属性,它们都支持现行的 HT ...

  9. 【python基础】 Tkinter小构件之canvas 画布

    [python之tkinter画布] 要画布就要使用tkinter的小构件,canvas(结构化的图形,用于绘制图形,创建图形编辑器以及实现自定制的小构件类) 我们先使用create_rectangl ...

随机推荐

  1. Oracle存储过程向Hadoop迁移中的问题及方案

    本文记录Oracle存储过程向Hadoop迁移中遇到的问题及响应的解决办法,作为初学者,文中内容有不妥之处欢迎指正, 1.不支持IN中的子查询,Solution,使用INNER JOIN将子查询操作添 ...

  2. Python 地点转化为经纬度

    1.geopy包下载地点https://pypi.python.org/pypi/geopy 2.安装步骤            运行cmd,切换到D:/python/geopy-1.11.0/目录下 ...

  3. NEL程序员专用轻钱包 进入0.01状态了

    这个轻钱包能干什么,现在就能在测试网看个余额,转个帐,调用个合约. 而且功能非常程序员化 你会说是不是没啥用   但是他有非常有用,因为他可以很容易的拼出NEOGUI拼不出来的交易 比如参与ICO交易 ...

  4. python class属性

    代码一: class A(object): pass a = A() a.name = "class_A" print(a.name) #class_A 代码二:class A(o ...

  5. Django实例

    更新:今年8月在深圳和嵩天老师居然见面了,很开心.嵩天老师很和蔼. =========== 今天看了嵩天老师的视频,感觉讲的很好,于是看着视频自己做了一个初步的实例认识. 步骤1,新建一个Web框架 ...

  6. css 网格布局简单应用

    将属性 display 值设为 grid 或 inline-grid 就创建了一个网格容器,所有容器直接子结点自动成为网格项目. grid :网格项目按行排列,网格项目占用整个容器的宽度. inlin ...

  7. 版本管理_git

    git 世界上最好的版本管理工具,分布式版本控制系统. 林纳斯-托瓦斯,自由主义教皇(git.linux) git 不管理空文件夹 对比于 SVN mkdir XX        创建一个空目录 XX ...

  8. [LeetCode] K-th Symbol in Grammar 语法中的第K个符号

    On the first row, we write a 0. Now in every subsequent row, we look at the previous row and replace ...

  9. 4、json-server的使用

    json-server 详解 转载于https://www.cnblogs.com/fly_dragon/p/9150732.html JSON-Server 是一个 Node 模块,运行 Expre ...

  10. 【C++】约瑟夫环(数组+链表)

    基于数组: #include<iostream> #include<cstring> #include<cstdlib> using namespace std; ...