HTML5 CSS3下雪奥运五环背景动画特效
代码片段:
var generateCanvasImageUrl = function generateCanvasImageUrl() {
var _window = window,
innerHeight = _window.innerHeight,
innerWidth = _window.innerWidth;
var pixels = innerHeight / 1 * (innerWidth / 1);
var $canvas = document.createElement('canvas');
var context = $canvas.getContext('2d');
$canvas.height = innerHeight / 1;
$canvas.width = innerWidth / 1;
for (var pixel = 0; pixel < pixels; pixel++) {
var x = pixel % innerWidth;
var y = Math.floor(pixel / innerWidth);
var size = Math.floor(Math.random() * 3 + 1);
context.fillStyle = '#fff';
if (Math.random() > 0.9999) context.fillRect(x, y, size, size);
}
return $canvas.toDataURL();
};
申明:本站所有资源都是转载各大下载站,或由网友投稿发布,请自行检测软件的完整性,如有侵权请联系我们删除下架,联系方式:admin@php.cn