├── Canvas星星跟流星背景动画特效 └── index.html ├── Canvas梦幻大树生长动画特效 ├── index.html ├── js │ └── jquery-1.4.2.min.js └── 说明.txt ├── Canvas粒子线条连接动态背景特效 ├── index.html ├── js │ └── jquery.min.js └── 说明.txt ├── Canvas自适应宽度大转盘抽奖代码 ├── images │ ├── 1.png │ ├── 10.png │ ├── 11.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 9.png │ ├── body_bg.jpg │ ├── body_bg2.jpg │ ├── cj_bg.png │ ├── eventDetails.jpg │ ├── jt.png │ ├── jt2.png │ ├── red5.png │ ├── red6.png │ ├── turnplate-bg.png │ └── turnplate-pointer.png ├── index.html ├── js │ ├── awardRotate.js │ └── jquery-1.10.2.js ├── 说明.htm └── 说明.txt ├── Canvas菱角背景动画特效 ├── index.html ├── js │ ├── Stats.min.js │ └── TweenMax.min.js └── 说明.txt ├── Canvas酷炫全屏动态背景动画特效 ├── css │ └── style.css ├── index.html └── js │ ├── TweenMax.min.js │ ├── index.js │ ├── jquery.min.js │ ├── jrj6out.js │ ├── prefixfree.min.js │ └── three.min.js ├── Canvas雪花散开放大动画特效 ├── index.html └── js │ └── jquery.min.js ├── Canvas鼠标箭头跟随动画特效 ├── demo.html ├── index.html └── js │ └── jquery.min.js ├── Canvas鼠标经过星星连成线特效 ├── demo.html ├── demo2.html ├── index.html └── 说明.txt ├── H5lock ├── H5lock.js ├── index.html └── 说明.htm ├── HTML5 Canvas岩浆动画背景特效 ├── index.html └── js │ ├── chroma.min.js │ └── dat.gui.min.js ├── HTML5 Canvas气泡背景特效 ├── demo.html ├── index.html └── js │ ├── background.js │ └── background.min.js ├── HTML5 Canvas点击泡沫横飞特效 ├── index.html └── js │ ├── Stats.min.js │ └── three.min.js ├── HTML5 Canvas粒子数字时钟特效 ├── index.html └── 说明.txt ├── HTML5 Canvas粒子文字特效 └── index.html ├── HTML5 Canvas赛车游戏动画 ├── css │ ├── normalize.css │ └── style.css ├── index.html └── js │ └── main.js ├── HTML5 canvas写字板涂鸦画板 ├── index.html └── js │ ├── huabu.js │ └── jquery.min.js ├── HTML5 canvas制作海浪动画效果 ├── css │ └── style.css ├── index.html ├── js │ └── ctx.js └── 说明.htm ├── HTML5 canvas扑克牌花式洗牌动画 ├── demo.html └── js │ └── jquery.min.js ├── HTML5 canvas移动端手机刮刮卡代码 ├── css │ └── style.css ├── images │ ├── foreground.jpg │ ├── loose.jpg │ ├── piece.cur │ ├── piece.png │ ├── scratch-over.jpg │ └── win.jpg ├── index.html └── js │ └── Scratch.js ├── HTML5 canvas简单五子棋小游戏 ├── index.html └── 说明.htm ├── HTML5 canvas粒子烟花绽放动画 └── index.html ├── HTML5 canvas绘制七巧板代码 ├── index.html └── 说明.htm ├── HTML5 canvas网页背景生成器 ├── css │ └── style.css ├── index.html └── js │ └── index.js ├── HTML5 canvas高通量能量线条动画 ├── demo.html └── js │ ├── perlin.js │ └── three.js ├── canvas1-loading ├── css │ └── style.css ├── index.html └── js │ └── index.js ├── canvas2-xjx-line └── index.html ├── canvas3-Snake ├── index.html └── js │ ├── RetroSnaker.js │ └── RetroSnaker.min.js ├── canvas4-paperdrop └── index.html ├── canvas5-rainbow ├── css │ └── style.css ├── index.html ├── js │ └── index.js └── scss │ └── style.scss ├── canvas6-squareroundtext ├── css │ └── style.css ├── index.html └── js │ ├── index.js │ ├── particles.js │ ├── shape.js │ ├── sidebar.js │ └── utils.js ├── canvas贪吃蛇 └── index.html ├── canvas通过sin实现波动线条 ├── README.txt ├── css │ └── style.css ├── index.html ├── js │ ├── index.js │ └── sine-waves.min.js ├── license.txt ├── scss │ └── style.scss └── 说明.htm ├── canvas黑客帝国代码雨特效 ├── index.html └── 说明.htm ├── demo ├── demo2.html ├── demo4.html ├── index1.html ├── index3.html └── index5.html ├── html5 canvas游动的水母特效 ├── index.html └── js │ └── jquery.min.js └── 俄罗斯方块 ├── audio └── bg.wav ├── css ├── 4.css └── bootstrap.min.black.css ├── images ├── 1.jpg └── blocks.png ├── index.html ├── js ├── Block.js ├── Board.js ├── Canvas.js ├── Keyboard.js ├── Leval.js ├── Nextshape.js ├── ResourceManager.js ├── Score.js ├── Shape.js ├── Tetris.js ├── Timer.js ├── app.js ├── config.js └── highscore.js ├── vendor └── howler.min.js └── 说明.htm /Canvas星星跟流星背景动画特效/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |适用浏览器:360、FireFox、Chrome、Opera、傲游、搜狗、世界之窗. 不支持Safari、IE8及以下浏览器。
293 |来源:A5源码
294 |适用浏览器:360、FireFox、Chrome、Opera、傲游、搜狗、世界之窗. 不支持Safari、IE8及以下浏览器。
221 |来源:A5源码
222 |适用浏览器:360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗. 不支持IE8及以下浏览器。
38 |来源:A5源码
39 |来源:A5源码
21 |更多源码:A5源码
77 |来源:A5源码
23 |在这个例子中,当你刮开90%的面积时,回调函数就会被执行。
16 |来源:A5源码
60 |来源:A5源码
19 |来源:A5源码
22 |更多源码:A5源码
154 |来源:A5源码
38 |18 | 圆形 19 | 方块 20 |
21 |文字
22 | 23 |重力
24 | 25 |周期
26 | 27 |速度
28 | 29 |半径
30 | 31 |分辨率
32 | 33 |*** 点击菜单按钮,滑出侧边栏,进行参数控制 ***
43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /canvas6-squareroundtext/js/index.js: -------------------------------------------------------------------------------- 1 | var canvas = document.getElementById('canvas'); 2 | context = canvas.getContext('2d'); 3 | W = canvas.width = window.innerWidth; 4 | H = canvas.height = window.innerHeight; 5 | gridY = 7, gridX = 7; 6 | 7 | type = "ball"; 8 | 9 | colors = [ 10 | '#f44336', '#e91e63', '#9c27b0', '#673ab7', '#3f51b5', 11 | '#2196f3', '#03a9f4', '#00bcd4', '#009688', '#4CAF50', 12 | '#8BC34A', '#CDDC39', '#FFEB3B', '#FFC107', '#FF9800', 13 | '#FF5722' 14 | ]; 15 | 16 | var message = document.getElementById('message'), 17 | gravity = document.getElementById('gra'), 18 | duration = document.getElementById('dur'), 19 | speed = document.getElementById('speed'), 20 | radius = document.getElementById('rad'), 21 | resolution = document.getElementById('res'); 22 | 23 | graVal = parseFloat(gravity.value); 24 | durVal = parseFloat(duration.value); 25 | spdVal = parseFloat(speed.value); 26 | radVal = parseFloat(radius.value); 27 | resVal = parseFloat(resolution.value); 28 | 29 | var word = new Shape(W/2, H/2, message.value); 30 | word.getValue(); 31 | 32 | function change(){ 33 | context.clearRect(0, 0, W, H); 34 | gridX = parseFloat(resolution.value); 35 | gridY = parseFloat(resolution.value); 36 | word.placement = []; 37 | word.text = message.value; 38 | word.getValue(); 39 | } 40 | 41 | function changeV() { 42 | graVal = parseFloat(gravity.value); 43 | durVal = parseFloat(duration.value); 44 | spdVal = parseFloat(speed.value); 45 | radVal = parseFloat(radius.value); 46 | } 47 | 48 | 49 | (function drawFrame(){ 50 | window.requestAnimationFrame(drawFrame, canvas); 51 | context.clearRect(0, 0, W, H); 52 | 53 | for(var i=0; i< word.placement.length; i++){ 54 | word.placement[i].update(); 55 | } 56 | }()) 57 | 58 | //resize 59 | function resize(){ 60 | W = canvas.width = window.innerWidth; 61 | H = canvas.height = window.innerHeight; 62 | } 63 | 64 | window.addEventListener('resize', resize, false); 65 | -------------------------------------------------------------------------------- /canvas6-squareroundtext/js/particles.js: -------------------------------------------------------------------------------- 1 | function Particle(x, y, type) { 2 | this.radius = 1.1; 3 | this.futurRadius = utils.randomInt(radVal, radVal+3); //[1.1,5.1] 4 | 5 | this.rebond = utils.randomInt(1, 5); 6 | this.x = x; 7 | this.y = y; 8 | 9 | this.dying = false; 10 | 11 | this.base = [x, y]; 12 | 13 | this.vx = 0; 14 | this.vy = 0; 15 | this.type = type; 16 | this.friction = .99; 17 | this.gravity = graVal; 18 | this.color = colors[Math.floor(Math.random() * colors.length)]; 19 | 20 | this.getSpeed = function() { 21 | return Math.sqrt(this.vx * this.vx + this.vy * this.vy); 22 | }; 23 | 24 | this.setSpeed = function(speed) { 25 | var heading = this.getHeading(); 26 | this.vx = Math.cos(heading) * speed; 27 | this.vy = Math.sin(heading) * speed; 28 | }; 29 | 30 | this.getHeading = function() { 31 | return Math.atan2(this.vy, this.vx); 32 | }; 33 | 34 | this.setHeading = function(heading) { 35 | var speed = this.getSpeed(); 36 | this.vx = Math.cos(heading) * speed; 37 | this.vy = Math.sin(heading) * speed; 38 | }; 39 | 40 | this.update = function(heading) { 41 | this.x += this.vx; 42 | this.y += this.vy; 43 | this.vy += graVal; 44 | 45 | this.vx *= this.friction; 46 | this.vy *= this.friction; 47 | 48 | if(this.radius < this.futurRadius && this.dying === false){ 49 | this.radius += durVal; 50 | }else{ 51 | this.dying = true; 52 | } 53 | 54 | if(this.dying === true){ 55 | this.radius -= durVal; 56 | } 57 | 58 | if(type === "ball"){ 59 | context.save(); 60 | context.fillStyle = this.color; 61 | context.beginPath(); 62 | context.arc(this.x, this.y, this.radius, Math.PI * 2, false); 63 | context.closePath(); 64 | context.fill(); 65 | context.restore(); 66 | } 67 | 68 | if(type === "rect"){ 69 | context.save(); 70 | context.fillStyle = this.color; 71 | context.beginPath(); 72 | context.fillRect(this.x, this.y, this.futurRadius, this.futurRadius) 73 | context.closePath(); 74 | context.fill(); 75 | context.restore(); 76 | } 77 | 78 | 79 | if (this.y < 0 || this.radius < 1) { 80 | this.x = this.base[0]; 81 | this.y = this.base[1]; 82 | this.dying = false; 83 | this.radius = 1.1; 84 | this.setSpeed(spdVal); 85 | this.futurRadius = utils.randomInt(radVal, radVal+3); 86 | this.setHeading(utils.randomInt(utils.degreesToRads(0), utils.degreesToRads(360))); 87 | } 88 | 89 | } 90 | 91 | this.setSpeed(utils.randomInt(.1, .5)); 92 | this.setHeading(utils.randomInt(utils.degreesToRads(0), utils.degreesToRads(360))); 93 | 94 | } 95 | -------------------------------------------------------------------------------- /canvas6-squareroundtext/js/shape.js: -------------------------------------------------------------------------------- 1 | function Shape(x, y, texte){ 2 | this.x = x; 3 | this.y = y; 4 | this.size = 150; 5 | 6 | this.text = texte; 7 | this.placement = []; 8 | //this.vectors = []; 9 | } 10 | 11 | /*//idata 为一个对象 12 | var idata = cxt.getImageData(0, 0, W, H); 13 | 14 | ImageData {data: Uint8ClampedArray[1885276], width: 733, height: 643} 15 | data:Uint8ClampedArray[1885276] //8位无符号整形数组 16 | height 17 | :643 18 | width:733 19 | 20 | var buffer32 = new Uint32Array(idata.data.buffer); 21 | /* 22 | 将8位无符号整形数组,转换成32位的,范围为[471318] 23 | */ 24 | Shape.prototype.getValue = function(){ 25 | 26 | //draw the shape 27 | context.textAlign = "center"; 28 | context.font = this.size + "px arial"; 29 | context.fillText(this.text, this.x, this.y); 30 | 31 | var idata = context.getImageData(0, 0, W, H); 32 | var buffer32 = new Uint32Array(idata.data.buffer); 33 | 34 | for(var j=0; j < H; j += gridY){ 35 | for(var i=0 ; i < W; i += gridX){ 36 | if(buffer32[j * W + i]){ 37 | var particle = new Particle(i, j, type); 38 | this.placement.push(particle); 39 | } 40 | } 41 | } 42 | 43 | context.clearRect(0, 0, W, H); 44 | 45 | } 46 | 47 | 48 | -------------------------------------------------------------------------------- /canvas6-squareroundtext/js/sidebar.js: -------------------------------------------------------------------------------- 1 | //侧边栏 2 | var btn = document.getElementById("btn"); 3 | var control = document.getElementById("control"); 4 | 5 | btn.addEventListener('click', function(e){ 6 | control.classList.toggle("slide"); 7 | }, false) 8 | 9 | 10 | //粒子选择 11 | var ball = document.getElementById("ball"); 12 | var rect = document.getElementById("rect"); 13 | 14 | function chose(particleName){ 15 | particleName.addEventListener('click', function(e){ 16 | this.style.backgroundColor = "orange"; 17 | (particleName == ball ? rect : ball).style.backgroundColor = "rgba(0, 0, 0, 0)"; 18 | type = (type === "ball" ? "rect" : "ball"); 19 | change(); 20 | 21 | }, false) 22 | } 23 | 24 | chose(ball); 25 | chose(rect); -------------------------------------------------------------------------------- /canvas6-squareroundtext/js/utils.js: -------------------------------------------------------------------------------- 1 | var utils = { 2 | norm: function(value, min, max) { 3 | return (value - min) / (max - min); 4 | }, 5 | 6 | lerp: function(norm, min, max) { 7 | return (max - min) * norm + min; 8 | }, 9 | 10 | map: function(value, sourceMin, sourceMax, destMin, destMax) { 11 | return utils.lerp(utils.norm(value, sourceMin, sourceMax), destMin, destMax); 12 | }, 13 | 14 | clamp: function(value, min, max) { 15 | return Math.min(Math.max(value, Math.min(min, max)), Math.max(min, max)); 16 | }, 17 | 18 | distance: function(p0, p1) { 19 | var dx = p1.x - p0.x, 20 | dy = p1.y - p0.y; 21 | return Math.sqrt(dx * dx + dy * dy); 22 | }, 23 | 24 | distanceXY: function(x0, y0, x1, y1) { 25 | var dx = x1 - x0, 26 | dy = y1 - y0; 27 | return Math.sqrt(dx * dx + dy * dy); 28 | }, 29 | 30 | circleCollision: function(c0, c1) { 31 | return utils.distance(c0, c1) <= c0.radius + c1.radius; 32 | }, 33 | 34 | circlePointCollision: function(x, y, circle) { 35 | return utils.distanceXY(x, y, circle.x, circle.y) < circle.radius; 36 | }, 37 | 38 | pointInRect: function(x, y, rect) { 39 | return utils.inRange(x, rect.x, rect.x + rect.radius) && 40 | utils.inRange(y, rect.y, rect.y + rect.radius); 41 | }, 42 | 43 | inRange: function(value, min, max) { 44 | return value >= Math.min(min, max) && value <= Math.max(min, max); 45 | }, 46 | 47 | rangeIntersect: function(min0, max0, min1, max1) { 48 | return Math.max(min0, max0) >= Math.min(min1, max1) && 49 | Math.min(min0, max0) <= Math.max(min1, max1); 50 | }, 51 | 52 | rectIntersect: function(r0, r1) { 53 | return utils.rangeIntersect(r0.x, r0.x + r0.width, r1.x, r1.x + r1.width) && 54 | utils.rangeIntersect(r0.y, r0.y + r0.height, r1.y, r1.y + r1.height); 55 | }, 56 | 57 | degreesToRads: function(degrees) { 58 | return degrees / 180 * Math.PI; 59 | }, 60 | 61 | radsToDegrees: function(radians) { 62 | return radians * 180 / Math.PI; 63 | }, 64 | 65 | randomRange: function(min, max) { 66 | return min + Math.random() * (max - min); 67 | }, 68 | 69 | randomInt: function(min, max) { 70 | return min + Math.random() * (max - min + 1); 71 | }, 72 | 73 | getmiddle: function(p0, p1) { 74 | var x = p0.x, 75 | x2 = p1.x; 76 | middlex = (x + x2) / 2; 77 | var y = p0.y, 78 | y2 = p1.y; 79 | middley = (y + y2) / 2; 80 | pos = [middlex, middley]; 81 | 82 | return pos; 83 | }, 84 | 85 | getAngle: function(p0, p1) { 86 | var deltaX = p1.x - p0.x; 87 | var deltaY = p1.y - p0.y; 88 | var rad = Math.atan2(deltaY, deltaX); 89 | return rad; 90 | }, 91 | inpercentW: function(size) { 92 | return (size * W) / 100; 93 | }, 94 | 95 | inpercentH: function(size) { 96 | return (size * H) / 100; 97 | }, 98 | 99 | } -------------------------------------------------------------------------------- /canvas通过sin实现波动线条/README.txt: -------------------------------------------------------------------------------- 1 | A Pen created at CodePen.io. You can find this one at http://codepen.io/egrucza/pen/WbmpqO. 2 | 3 | Working on a few different styles of sine waves. Utilizes sine-waves.js by Isaac Suttell. 4 | 5 | *Update* I forked this pen and created a new version with the ability to toggle wave types. You can find it here http://codepen.io/egrucza/pen/raRGGR -------------------------------------------------------------------------------- /canvas通过sin实现波动线条/css/style.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | height: 100%; 3 | width: 100%; 4 | background-color: black; 5 | overflow-x: hidden; 6 | } 7 | -------------------------------------------------------------------------------- /canvas通过sin实现波动线条/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |12 | 13 | 14 |
15 |↑ 翻转方块
32 |↓ 加速下落
33 |→ 向右移动
34 |← 向左移动
35 |