人物画像————圆球转动效果

前言:

<!doctype html>
<html>

	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<title>人物画像</title>
		<meta name="author" content="hongru.chen" />
		<style type="text/css">
			html {
				overflow: hidden
			}
			
			body,
			.screen {
				overflow: hidden;
				width: 500px;
				height: 500px;
				position: absolute;
				margin: 0;
				padding: 0;
				border: 1px solid red;
			}
			
			#screen {
				left: 0;
				top: 0;
				zoom: 1;
			}
			
			#screen a {
				position: absolute;
				font-size: 12px;
				overflow: hidden;
				padding: 1px 2px;
				font-weight: bold;
			}
			
			#screen a:hover {
				border: 1px solid #ccc;
				background: #666
			}
		</style>
		
		
		<script src="jquery.min.js"></script>
		<script type="text/javascript">
			var tt="";
			var BeautifullMath = function() {
				var obj = [],
					xm = 0,
					ym = 0,
					axe = 0,
					aye = 0,
					parts = 50,
					scr, aArr, txe, tye, nw, nh;
				var colorArr = ['black', 'blue', 'red', 'green', 'yellow'];
				var addEvent = function(o, e, f) {
					window.addEventListener ? o.addEventListener(e, f, false) : o.attachEvent('on' + e, function() {
						f.call(o)
					})
				}
				var resize = function() {
					nw = scr.offsetWidth * .5;
					nh = scr.offsetHeight * .5;
				}
				var init = function(id, f) {
					scr = document.getElementById(id);
					aArr = document.getElementsByTagName('a');
					
//					function fun(e){
//						e = e || window.event;
//						xm = e.clientX;
//						ym = e.clientY;
//					}
					addEvent(document, 'mousemove', function(e) {
//						fun(e);
//						console.log(e.target)
						console.log(e.target.tagName)
						if(e.target.tagName == "A"){
							return false;
							clearInterval(tt);
						}
						e = e || window.event;
						xm = e.clientX;
						ym = e.clientY;
						
					});
					resize();
					addEvent(window, 'resize', resize);
					__init(f);
					tt = setInterval(run, 10);
				}
				var __init = function(f) {
					for(var i = 0; i < aArr.length; i++) {
						var o = {};
						o.p = aArr[i];
						o.p.style.color = colorArr[Math.round(Math.random() * 4)];
						var r = i / parts,
							j, a, b;
						j = i % parts;
//						a = Math.floor(j) / 200 + (Math.floor(j / 2) % 10) / 5 * Math.PI * 2;
						a = Math.floor(j) / 50 + (Math.floor(j / 2) % 10) / 5 * Math.PI * 2;
						b = Math.acos(-0.9 + (j % 4) * 0.6);
						r = !!f ? f(r) : r - r * r + .5;
						var sbr = Math.sin(b) * r;
						o.x = Math.sin(a) * sbr;
						o.y = Math.cos(a) * sbr;
						o.z = Math.cos(b) * r;
						obj.push(o);
						o.transform = function() {
							var ax = .02 * txe,
								ay = .02 * tye,
								cx = Math.cos(ax),
								sx = Math.sin(ax),
								cy = Math.cos(ay),
								sy = Math.sin(ay);
							//rotation
							var z = this.y * sx + this.z * cx;
							this.y = this.y * cx + this.z * -sx;
							this.z = this.x * -sy + z * cy;
							this.x = this.x * cy + z * sy;
							//3d
							var scale = 1.3 / (1 + this.z),
								x = this.x * scale * nh + nw - scale * 2,
								y = this.y * scale * nh + nh - scale * 2;
							//set style
							var p = this.p.style;
							if(x >= 0 && y >= 0 && x < nw * 2 && y < nh * 2) {
								var c = Math.round(256 + (-this.z * 256));
								p.left = Math.round(x) + 'px';
								p.top = Math.round(y) + 'px';
								p.fontSize = Math.round(14 * scale) + 'px';
//								p.fontSize = (Math.random()*50 +scale)  + 'px';
								p.zIndex = 200 + Math.floor(-this.z * 100);
								p.opacity = .6 - this.z;
								p.filter = 'alpha(opacity=' + 100 * (.6 - this.z) + ')';
							} else p.width = "0px";
						}
					}
				}
				//run function 
				var run = function() {
					var se = 1 / nh;
					txe = (ym - axe) * se;
					tye = (xm - aye) * se;
					axe += txe;
					aye += tye;
					
					/* ---- anim particles ---- */
					for(var i = 0, o; o = obj[i]; i++) o.transform();
				}
				return {
					init: init
				}
			}();
			onload = function() {
				BeautifullMath.init('screen', function(r) {
					return .4;
				});
			}
		</script>
	</head>

	<body>
		<div id="screen" class="screen">
			<a href="http://www.cnblogs.com/hongru/">老腊肉666</a>
			<a href="http://www.cnblogs.com/hongru/">老腊肉666</a>
			<a href="http://www.cnblogs.com/hongru/">老腊肉666</a>
			<a href="http://www.cnblogs.com/hongru/">老腊肉666</a>
			<a href="http://www.cnblogs.com/hongru/">老腊肉666</a>
			<a href="http://www.cnblogs.com/hongru/">老腊肉666</a>
			<a href="http://www.cnblogs.com/hongru/">老腊肉666</a>
			<a href="http://www.cnblogs.com/hongru/">老腊肉666</a>
			<a href="http://www.cnblogs.com/hongru/">老腊肉666</a>
			<a href="http://www.cnblogs.com/hongru/">老腊肉666</a>
		</div>
	</body>

</html>

 

2020/09/22扩展,自动匀速旋转


1、去掉鼠标移入效果

2、修改滚动方向

 

<!doctype html>
<html>
 
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<title>人物画像</title>
		<meta name="author" content="hongru.chen" />
		<style type="text/css">
			html {
				overflow: hidden
			}
			
			body,
			.screen {
				overflow: hidden;
				width: 500px;
				height: 500px;
				position: absolute;
				margin: 0;
				padding: 0;
				border: 1px solid red;
			}
			
			#screen {
				left: 0;
				top: 0;
				zoom: 1;
			}
			
			#screen a {
				position: absolute;
				font-size: 12px;
				overflow: hidden;
				padding: 1px 2px;
				font-weight: bold;
			}
			
			#screen a:hover {
				border: 1px solid #ccc;
				background: #666
			}
		</style>
		
		
		<script src="jquery.min.js"></script>
		<script type="text/javascript">
			var tt="";
			var BeautifullMath = function() {
				var obj = [],
					xm = 0,
					ym = 0,
					axe = 0,
					aye = 0,
					parts = 50,
					scr, aArr, txe, tye, nw, nh;
				var colorArr = ['black', 'blue', 'red', 'green', 'yellow'];
				var addEvent = function(o, e, f) {
					window.addEventListener ? o.addEventListener(e, f, false) : o.attachEvent('on' + e, function() {
						f.call(o)
					})
				}
				var resize = function() {
					nw = scr.offsetWidth * .5;
					nh = scr.offsetHeight * .5;
				}
				var init = function(id, f) {
					scr = document.getElementById(id);
					aArr = document.getElementsByTagName('a');
					
//					function fun(e){
//						e = e || window.event;
//						xm = e.clientX;
//						ym = e.clientY;
//					}
//					addEvent(document, 'mousemove', function(e) {
//						fun(e);
//						console.log(e.target)
//						console.log(e.target.tagName)
//						if(e.target.tagName == "A"){
//							return false;
//							clearInterval(tt);
//						}
//						e = e || window.event;
//						xm = e.clientX;
//						ym = e.clientY;
//						
//					});
					resize();
					addEvent(window, 'resize', resize);
					__init(f);
					tt = setInterval(run, 10);
				}
				var __init = function(f) {
					for(var i = 0; i < aArr.length; i++) {
						var o = {};
						o.p = aArr[i];
						o.p.style.color = colorArr[Math.round(Math.random() * 4)];
						var r = i / parts,
							j, a, b;
						j = i % parts;
//						a = Math.floor(j) / 200 + (Math.floor(j / 2) % 10) / 5 * Math.PI * 2;
						a = Math.floor(j) / 50 + (Math.floor(j / 2) % 10) / 5 * Math.PI * 2;
						b = Math.acos(-0.9 + (j % 4) * 0.6);
						r = !!f ? f(r) : r - r * r + .5;
						var sbr = Math.sin(b) * r;
						o.x = Math.sin(a) * sbr;
						o.y = Math.cos(a) * sbr;
						o.z = Math.cos(b) * r;
						obj.push(o);
						o.transform = function() {
							var ax = .02 * txe,
								ay = .02 * tye,
								cx = Math.cos(ax),
								sx = Math.sin(ax),
								cy = Math.cos(ay),
								sy = Math.sin(ay);
							//rotation
							var z = this.y * sx + this.z * cx;
							this.y = this.y * cx + this.z * -sx;
							this.z = this.x * -sy + z * cy;
							this.x = this.x * cy + z * sy;
							//3d
							var scale = 1.3 / (1 + this.z),
								x = this.x * scale * nh + nw - scale * 2,
								y = this.y * scale * nh + nh - scale * 2;
							//set style
							var p = this.p.style;
							if(x >= 0 && y >= 0 && x < nw * 2 && y < nh * 2) {
								var c = Math.round(256 + (-this.z * 256));
								p.left = Math.round(x) + 'px';
								p.top = Math.round(y) + 'px';
								p.fontSize = Math.round(14 * scale) + 'px';
//								p.fontSize = (Math.random()*50 +scale)  + 'px';
								p.zIndex = 200 + Math.floor(-this.z * 100);
								p.opacity = .6 - this.z;
								p.filter = 'alpha(opacity=' + 100 * (.6 - this.z) + ')';
							} else p.width = "0px";
						}
					}
				}
				//run function 
				var run = function() {
					var se = 1 / nh;
					
//					axe=100//绝对值越大,速度越快
//					aye=100//绝对值越大,速度越快
					
					axe=-100//绝对值越大,速度越快
					aye=-100//绝对值越大,速度越快
					
					
					txe = (ym - axe) * se;
					tye = (xm - aye) * se;
					axe += txe;
					aye += tye;
					
					/* ---- anim particles ---- */
					for(var i = 0, o; o = obj[i]; i++) o.transform();
				}
				return {
					init: init
				}
			}();
			onload = function() {
				BeautifullMath.init('screen', function(r) {
					return .4;
				});
			}
		</script>
	</head>
 
	<body>
		<div id="screen" class="screen">
			<a href="http://www.cnblogs.com/hongru/">老腊肉666</a>
			<a href="http://www.cnblogs.com/hongru/">老腊肉666</a>
			<a href="http://www.cnblogs.com/hongru/">老腊肉666</a>
			<a href="http://www.cnblogs.com/hongru/">老腊肉666</a>
			<a href="http://www.cnblogs.com/hongru/">老腊肉666</a>
			<a href="http://www.cnblogs.com/hongru/">老腊肉666</a>
			<a href="http://www.cnblogs.com/hongru/">老腊肉666</a>
			<a href="http://www.cnblogs.com/hongru/">老腊肉666</a>
			<a href="http://www.cnblogs.com/hongru/">老腊肉666</a>
			<a href="http://www.cnblogs.com/hongru/">老腊肉666</a>
		</div>
	</body>
 
</html>

效果:

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值