Home >Web Front-end >H5 Tutorial >Miaowei Classroom HTML5 video material sharing

Miaowei Classroom HTML5 video material sharing

巴扎黑
巴扎黑Original
2017-08-31 14:21:412524browse

The fifth major revision of Hypertext Markup Language (HTML), the core language of the World Wide Web and an application under Standard Universal Markup Language (this is a recommended standard, foreign language original text: W3C Recommendation, see the original text of this reference :).

On October 29, 2014, the World Wide Web Consortium announced that after nearly 8 years of hard work, the standard specification was finally completed.

"Miaowei Classroom HTML5 Video Tutorial" will introduce the fifth major modification of Hypertext Markup Language (HTML), which is the latest version; it adds some new tags than the original standard and achieves more Functions are more standardized and more suitable for mobile Internet.

Miaowei Classroom HTML5 video material sharing

Video playback address: http://www.php.cn/course/418.html

Difficulties in learning this video It depends on the usage of canvas:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>仿知乎背景canvas特效</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<style type="text/css">
body{
text-align: center;
background: #F7FAFC;
overflow: hidden;
background: #fff;
}
</style>
</head>
<body>
<canvas id="Mycanvas"></canvas>
<script>
//定义画布宽高和生成点的个数
var WIDTH = window.innerWidth, HEIGHT = window.innerHeight, POINT = 35;
var canvas = document.getElementById(&#39;Mycanvas&#39;);
canvas.width = WIDTH,
canvas.height = HEIGHT;
var context = canvas.getContext(&#39;2d&#39;);
context.strokeStyle = &#39;rgba(0,0,0,0.2)&#39;,
context.strokeWidth = 1,
context.fillStyle = &#39;rgba(0,0,0,0.1)&#39;;
var circleArr = [];
//线条:开始xy坐标,结束xy坐标,线条透明度
function Line (x, y, _x, _y, o) {
this.beginX = x,
this.beginY = y,
this.closeX = _x,
this.closeY = _y,
this.o = o;
}
//点:圆心xy坐标,半径,每帧移动xy的距离
function Circle (x, y, r, moveX, moveY) {
this.x = x,
this.y = y,
this.r = r,
this.moveX = moveX,
this.moveY = moveY;
}
//生成max和min之间的随机数
function num (max, _min) {
var min = arguments[1] || 0;
return Math.floor(Math.random()*(max-min+1)+min);
}
// 绘制原点
function drawCricle (cxt, x, y, r, moveX, moveY) {
var circle = new Circle(x, y, r, moveX, moveY)
cxt.beginPath()
cxt.arc(circle.x, circle.y, circle.r, 0, 2*Math.PI)
cxt.closePath()
cxt.fill();
return circle;
}
//绘制线条
function drawLine (cxt, x, y, _x, _y, o) {
var line = new Line(x, y, _x, _y, o)
cxt.beginPath()
cxt.strokeStyle = &#39;rgba(0,0,0,&#39;+ o +&#39;)&#39;
cxt.moveTo(line.beginX, line.beginY)
cxt.lineTo(line.closeX, line.closeY)
cxt.closePath()
cxt.stroke();
}
//每帧绘制
function draw () {
context.clearRect(0,0,canvas.width, canvas.height);
for (var i = 0; i < POINT; i++) {
drawCricle(context, circleArr[i].x, circleArr[i].y, circleArr[i].r);
}
for (var i = 0; i < POINT; i++) {
for (var j = 0; j < POINT; j++) {
if (i + j < POINT) {
var A = Math.abs(circleArr[i+j].x - circleArr[i].x),
B = Math.abs(circleArr[i+j].y - circleArr[i].y);
var lineLength = Math.sqrt(A*A + B*B);
var C = 1/lineLength*7-0.009;
var lineOpacity = C > 0.03 ? 0.03 : C;
if (lineOpacity > 0) {
drawLine(context, circleArr[i].x, circleArr[i].y, circleArr[i+j].x, circleArr[i+j].y, lineOpacity);
}
}
}
}
}
//初始化生成原点
function init () {
circleArr = [];
for (var i = 0; i < POINT; i++) {
circleArr.push(drawCricle(context, num(WIDTH), num(HEIGHT), num(15, 2), num(10, -10)/40, num(10, -10)/40));
}
draw();
}
//调用执行
window.onload = function () {
init();
setInterval(function () {
for (var i = 0; i < POINT; i++) {
var cir = circleArr[i];
cir.x += cir.moveX;
cir.y += cir.moveY;
if (cir.x > WIDTH) cir.x = 0;
else if (cir.x < 0) cir.x = WIDTH;
if (cir.y > HEIGHT) cir.y = 0;
else if (cir.y < 0) cir.y = HEIGHT;
}
draw();
}, 10);
}
</script>
</body>
</html>

The above is the detailed content of Miaowei Classroom HTML5 video material sharing. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn