⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reflex.js

📁 一个在图像显示的时候具有镜面反射效果的javascript
💻 JS
📖 第 1 页 / 共 2 页
字号:
/** * reflex.js 1.1 (23-Aug-2007) * (c) by Christian Effenberger  * All Rights Reserved * Source: reflex.netzgesta.de * Distributed under Netzgestade Software License Agreement * http://www.netzgesta.de/cvi/LICENSE.txt * License permits free of charge * use on non-commercial and  * private web sites only **/var tmp = navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') < 1 ? 1 : 0;if(tmp) var isIE = document.namespaces ? 1 : 0;if(isIE) {	if(document.namespaces['v'] == null) {		var stl = document.createStyleSheet();		stl.addRule("v\\:*", "behavior: url(#default#VML);"); 		document.namespaces.add("v", "urn:schemas-microsoft-com:vml"); 	}}function getImages(className){	var children = document.getElementsByTagName('img'); 	var elements = new Array(); var i = 0;	var child; var classNames; var j = 0;	for (i=0;i<children.length;i++) {		child = children[i];		classNames = child.className.split(' ');		for (var j = 0; j < classNames.length; j++) {			if (classNames[j] == className) {				elements.push(child);				break;			}		}	}	return elements;}function getClasses(classes,string){	var temp = '';	for (var j=0;j<classes.length;j++) {		if (classes[j] != string) {			if (temp) {				temp += ' '			}			temp += classes[j];		}	}	return temp;}function getClassValue(classes,string){	var temp = 0; var pos = string.length;	for (var j=0;j<classes.length;j++) {		if (classes[j].indexOf(string) == 0) {			temp = Math.min(classes[j].substring(pos),100);			break;		}	}	return Math.max(0,temp);}function getClassColor(classes,string){	var temp = 0; var str = ''; var pos = string.length;	for (var j=0;j<classes.length;j++) {		if (classes[j].indexOf(string) == 0) {			temp = classes[j].substring(pos);			str = '#' + temp.toLowerCase();			break;		}	}	if(str.match(/^#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]$/i)) {return str; }else {return 0;}}function getClassAttribute(classes,string){	var temp = 0; var pos = string.length;	for (var j=0;j<classes.length;j++) {		if (classes[j].indexOf(string) == 0) {			temp = 1; 			break;		}	}	return temp;}function clipPolyRight(ctx,x,y,w,h,t,d,s) {	var z = (h-t-t)/h;	ctx.beginPath(); 	ctx.moveTo(x,y); ctx.lineTo(w,y+t); ctx.lineTo(w,y+h-t); ctx.lineTo(x,y+h);	if(d>0) {ctx.lineTo(x,y+h-s); ctx.lineTo(w,y+h-t-(z*s)); ctx.lineTo(w,y+h-t-(z*(s+d))); ctx.lineTo(x,y+h-s-d);}	ctx.closePath();}	function clipPolyLeft(ctx,x,y,w,h,t,d,s) {	var z = (h-t-t)/h;	ctx.beginPath(); 	ctx.moveTo(x,y+t); ctx.lineTo(w,y); ctx.lineTo(w,y+h); ctx.lineTo(x,y+h-t);	if(d>0) {ctx.lineTo(x,y+h-t-(z*s)); ctx.lineTo(w,y+h-s); ctx.lineTo(w,y+h-s-d); ctx.lineTo(x,y+h-t-(z*(s+d))); }	ctx.closePath();}	function strokePolyRight(ctx,x,y,w,h,t,d,s,b) {	var z = (h-t-t)/h; var n = (b>=1?1:0);	ctx.beginPath(); 	ctx.moveTo(x+b,y+b); ctx.lineTo(w-b,y+t+b-n); ctx.lineTo(w-b,y+h-t-(z*(s+d))-b); ctx.lineTo(x+b,y+h-s-d-b);	ctx.closePath();}function strokePolyLeft(ctx,x,y,w,h,t,d,s,b) {	var z = (h-t-t)/h; var n = (b>=1?1:0);	ctx.beginPath(); 	ctx.moveTo(x+b,y+t+b-n); ctx.lineTo(w-b,y+b); ctx.lineTo(w-b,y+h-s-d-b); ctx.lineTo(x+b,y+h-t-(z*(s+d))-b);	ctx.closePath();}function clipReflex(ctx,x,y,w,h,t,d,s,o) {	var z = (h-t-t)/h;	ctx.beginPath();	if(o=='r') {		ctx.moveTo(x,y+h-s); ctx.lineTo(w,y+h-t-(z*s)); ctx.lineTo(w,y+h-t+2); ctx.lineTo(x,y+h+2);	}else {		ctx.moveTo(w,y+h+2); ctx.lineTo(w,y+h-s); ctx.lineTo(x,y+h-t-(z*s)); ctx.lineTo(x,y+h-t+2); 	}	ctx.closePath();}function clearReflex(ctx,x,y,w,h,t,d,s,o) {	var z = (h-t-t)/h;	ctx.beginPath();	if(o=='r') {		ctx.moveTo(x,y+h-1); ctx.lineTo(w,y+h-t-1); ctx.lineTo(w,y+h-t+1); ctx.lineTo(x,y+h+1);	}else {		ctx.moveTo(w,y+h-1); ctx.lineTo(x,y+h-t-1); ctx.lineTo(x,y+h-t+1); ctx.lineTo(w,y+h+1);	}	ctx.closePath();}function addIEReflex() {	var theimages = getImages('reflex');	var image, object, vml, display, flt, classes, newClasses, head, fill, flex, foot;  	var i, j, z, q, p, dist, stl, iter, rest, radi, higt, divs, opac, colr, bord, wide, half, ih, iw, ww, hh, fb, xb;  	var itiltright, itiltnone, itiltleft, iheight, iopacity, idistance, iborder, icolor, iradius;	var children = document.getElementsByTagName('img'); var tilt = 'r';	for(i=0;i<theimages.length;i++) {			image = theimages[i]; object = image.parentNode; j = 0;		itiltright = 0; itiltnone = 0; itiltleft = 0; 		iheight = 33; iopacity = 33; idistance = 0;		iborder = 0; icolor = '#000000'; iradius = 0; 		if(image.width>=32 && image.height>=32) {			classes = image.className.split(' ');			iradius = getClassValue(classes,"iradius");			iborder = getClassValue(classes,"iborder");			iheight = getClassValue(classes,"iheight");			iopacity = getClassValue(classes,"iopacity");			idistance = getClassValue(classes,"idistance");			icolor = getClassColor(classes,"icolor");			itiltleft = getClassAttribute(classes,"itiltleft");			itiltright = getClassAttribute(classes,"itiltright");			itiltnone = getClassAttribute(classes,"itiltnone");			if(itiltright==true) tilt = 'r';			if(itiltnone==true) tilt = 'n';			if(itiltleft==true) tilt = 'l';			newClasses = getClasses(classes,"reflex");				ih = image.height; iw = image.width; dist = idistance; 			radi = Math.min(iradius,Math.max(iw,ih)/10);			colr = (icolor!=0?icolor:'#000000');			opac = (iopacity>0?iopacity:33);			divs = 100/(iheight>=10?iheight:33); 			p = (iheight>=10?iheight:33)/100;			higt = Math.floor(ih/divs); wide = 12;			if(iborder==1) { bord = 0; }else {				iborder = Math.floor(Math.round(Math.min(Math.min(iborder,higt/4),Math.max(iw,ih)/20))/2)*2;				bord = (iborder>0?iborder/2:0); 			}			ww = parseInt(iw/20); q = 1;			iter = Math.floor((iw-ww-ww)/wide); 			rest = ((iw-ww-ww)%wide); half = (((iw-ww-ww)/wide)-1)/2;			hh = iter+(rest>0?1:0); z = (ih-hh-hh)/ih;			display = (image.currentStyle.display.toLowerCase()=='block')?'block':'inline-block';			vml = document.createElement(['<var style="overflow:hidden;display:' + display + ';width:' + iw + 'px;height:' + (ih+higt+dist) + 'px;padding:0;">'].join(''));			flt = image.currentStyle.styleFloat.toLowerCase();			display = (flt=='left'||flt=='right')?'inline':display;			head = '<v:group style="zoom:1; display:' + display + '; margin:-1px 0 0 -1px; padding:0; position:relative; width:' + iw + 'px;height:' + (ih+higt+dist) + 'px;" coordsize="' + iw + ',' + (ih+higt+dist) + '">';			if(tilt=='n') {				fill = '<v:rect strokeweight="0" filled="t" stroked="f" fillcolor="#ffffff" style="position:absolute; margin:-1px 0 0 -1px; padding:0; top:0px; left:0px; width:' + iw + 'px;height:' + ih + 'px;"><v:fill src="' + image.src + '" type="frame" /></v:rect>';				fb = '<v:rect strokeweight="'+iborder+'" strokecolor="'+colr+'" filled="f" stroked="'+(bord>0||iborder>0?'t':'f')+'" fillcolor="#ffffff" style="position:absolute; margin:-1px 0 0 -1px; padding:0; top:'+bord+'px; left:'+bord+'px; width:'+(iw-bord-bord)+'px;height:'+(ih-bord-bord)+'px;"></v:rect>';				xb = '<v:rect strokeweight="'+iborder+'" strokecolor="'+colr+'" filled="f" stroked="'+(bord>0||iborder>0?'t':'f')+'" fillcolor="#ffffff" style="position:absolute; margin:-1px 0 0 -1px; padding:0; top:'+(ih+dist+bord)+'px; left:'+bord+'px; width:'+(iw-bord-bord)+'px;height:'+(higt-bord-bord)+'px; filter: progid:DXImageTransform.Microsoft.Alpha(opacity='+opac+',style=1,finishOpacity=0,startx=0,starty=0,finishx=0,finishy='+parseInt(ih*0.66)+');"></v:rect>';				flex = '<v:rect strokeweight="0" filled="t" stroked="f" fillcolor="#ffffff" style="position:absolute; margin:-1px 0 0 -1px; padding:0; top:'+(ih+dist)+'px; left:0px; width:' + iw + 'px;height:' + higt + 'px; filter:flipv progid:DXImageTransform.Microsoft.Alpha(opacity='+opac+',style=1,finishOpacity=0,startx=0,starty=0,finishx=0,finishy='+ih+');"><v:fill origin="0,0" position="0,-'+(divs/2-0.5)+'" size="1,'+(1*divs)+'" src="' + image.src + '" type="frame" /></v:rect>';			}else if(tilt=='r') {				fill = '<v:rect strokeweight="0" filled="t" stroked="f" fillcolor="#808080" style="position:absolute; margin:-1px 0 0 -1px;padding:0 ;width:' + iw + 'px;height:' + (ih+higt+dist) + 'px;"><v:fill color="#808080" opacity="0.0" /></v:rect><v:shape strokeweight="0" filled="t" stroked="f" fillcolor="#ffffff" coordorigin="0,0" coordsize="'+iw+','+ih+'" path="m '+ww+',0 l '+ww+','+ih+','+(iw-ww)+','+(ih-hh)+','+(iw-ww)+','+hh+' x e" style="position:absolute; margin:-1px 0 0 -1px; padding:0; top:0px; left:0px; width:' + iw + 'px;height:' + ih + 'px;"><v:fill src="' + image.src + '" type="frame" /></v:shape>';				for(j=0;j<iter;j++) {					if(j==(iter-1)) q = (rest>0?1:0);					fill += '<v:shape strokeweight="0" filled="t" stroked="f" fillcolor="#808080" coordorigin="0,0" coordsize="'+iw+','+ih+'" path="m '+(ww+(j*wide))+','+j+' l '+(q+ww+((j+1)*wide))+','+(j+1)+','+(q+ww+((j+1)*wide))+','+(ih-1-j)+','+(ww+(j*wide))+','+(ih-j)+' x e" style="position:absolute; margin: -1px 0 0 -1px; padding:0px; top:0px; left:0px; width:' + iw + 'px; height:' + ih + 'px;"><v:fill origin="0,0" position="'+(half-j)+',0" size="'+((iw-ww-ww)/wide)+',1" type="frame" src="' + image.src + '" /></v:shape>';				}				if(rest>0) {					fill += '<v:shape strokeweight="0" filled="t" stroked="f" fillcolor="#808080" coordorigin="0,0" coordsize="'+iw+','+ih+'" path="m '+(ww+(j*wide))+','+j+' l '+(ww+((j+1)*wide))+','+(j+1)+','+(ww+((j+1)*wide))+','+(ih-1-j)+','+(ww+(j*wide))+','+(ih-j)+' x e" style="position:absolute; margin: -1px 0 0 -1px; padding:0px; top:0px; left:0px; width:' + iw + 'px; height:' + ih + 'px;"><v:fill origin="0,0" position="'+(half-j)+',0" size="'+((iw-ww-ww)/wide)+',1" type="frame" src="' + image.src + '" /></v:shape>';				}				q = ((iter*z)/(ih/100))/2; 				if(bord>0||iborder>0) {					fb = '<v:shape strokeweight="'+iborder+'" strokecolor="'+colr+'" filled="f" stroked="'+(bord>0||iborder>0?'t':'f')+'" coordorigin="0,0" coordsize="'+iw+','+ih+'" path="m '+(ww+bord)+','+bord+' l '+(ww+bord)+','+(ih-bord)+','+(iw-ww-bord)+','+(ih-hh-bord)+','+(iw-ww-bord)+','+(hh+bord)+' x e" style="position:absolute; margin:-1px 0 0 -1px; padding:0; top:0px; left:0px; width:' + iw + 'px;height:' + ih + 'px;"></v:shape>';					xb = '<v:shape strokeweight="'+iborder+'" strokecolor="'+colr+'" stroked="'+(bord>0||iborder>0?'t':'f')+'" filled="f" coordorigin="0,0" coordsize="'+iw+','+(hh+higt+dist)+'" path="m '+(ww+bord)+','+(hh+dist+bord)+' l '+(ww+bord)+','+(higt+hh+dist-bord)+','+(iw-ww-bord)+','+(parseInt((higt+dist)*z)-bord)+','+(iw-ww-bord)+','+(parseInt(dist*z)+bord)+' x e" style="position:absolute; margin:-1px 0 0 -1px; padding:0; top:'+(ih-hh+dist)+'px; left:0px; width:' + iw + 'px;height:' + (hh+higt+dist) + 'px; flip: y; filter:flipv progid:DXImageTransform.Microsoft.Alpha(opacity='+opac+',style=1,finishOpacity=0,startx=0,starty=0,finishx='+q+',finishy=80);"></v:shape>';				}else {fb = ''; xb = ''; }					flex = '<v:shape strokeweight="0" stroked="f" filled="t" fillcolor="#808080" coordorigin="0,0" coordsize="'+iw+','+(hh+higt+dist)+'" path="m '+ww+','+(hh+dist)+' l '+ww+','+(higt+hh+dist)+','+(iw-ww)+','+parseInt((higt+dist)*z)+','+(iw-ww)+','+parseInt(dist*z)+' x e" style="position:absolute; margin:-1px 0 0 -1px; padding:0; top:'+(ih-hh+dist)+'px; left:0px; width:' + iw + 'px;height:' + (hh+higt+dist) + 'px; flip: y; filter:flipv progid:DXImageTransform.Microsoft.Alpha(opacity='+opac+',style=1,finishOpacity=0,startx=0,starty=0,finishx='+q+',finishy=90);"><v:fill origin="0,0" position="0,-'+((divs/2)-0.5)+'" size="1,'+(divs)+'" src="' + image.src + '" type="frame" /></v:shape>';			}else if(tilt=='l') {				fill = '<v:rect strokeweight="0" filled="t" stroked="f" fillcolor="#808080" style="position:absolute; margin:-1px 0 0 -1px;padding:0 ;width:' + iw + 'px;height:' + (ih+higt+dist) + 'px;"><v:fill color="#808080" opacity="0.0" /></v:rect><v:shape strokeweight="0" filled="t" stroked="f" fillcolor="#ffffff" coordorigin="0,0" coordsize="'+iw+','+ih+'" path="m '+ww+','+hh+' l '+ww+','+(ih-hh)+','+(iw-ww)+','+ih+','+(iw-ww)+',0 x e" style="position:absolute; margin:-1px 0 0 -1px; padding:0; top:0px; left:0px; width:' + iw + 'px;height:' + ih + 'px;"><v:fill src="' + image.src + '" type="frame" /></v:shape>';				for(j=0;j<iter;j++) {					if(j==(iter-1)) q = (rest>0?1:0);					fill += '<v:shape strokeweight="0" filled="t" stroked="f" fillcolor="#808080" coordorigin="0,0" coordsize="'+iw+','+ih+'" path="m '+(ww+(j*wide))+','+(iter-j)+' l '+(q+ww+((j+1)*wide))+','+(iter-1-j)+','+(q+ww+((j+1)*wide))+','+(ih-1-iter+j)+','+(ww+(j*wide))+','+(ih-iter+j)+' x e" style="position:absolute; margin: -1px 0 0 -1px; padding:0px; top:0px; left:0px; width:' + iw + 'px; height:' + ih + 'px;"><v:fill origin="0,0" position="'+(half-j)+',0" size="'+((iw-ww-ww)/wide)+',1" type="frame" src="' + image.src + '" /></v:shape>';				}				if(rest>0) {					fill += '<v:shape strokeweight="0" filled="t" stroked="f" fillcolor="#808080" coordorigin="0,0" coordsize="'+iw+','+ih+'" path="m '+(ww+(j*wide))+','+(iter-j)+' l '+(ww+((j+1)*wide))+','+(iter-1-j)+','+(ww+((j+1)*wide))+','+(ih-1-iter+j)+','+(ww+(j*wide))+','+(ih-iter+j)+' x e" style="position:absolute; margin: -1px 0 0 -1px; padding:0px; top:0px; left:0px; width:' + iw + 'px; height:' + ih + 'px;"><v:fill origin="0,0" position="'+(half-j)+',0" size="'+((iw-ww-ww)/wide)+',1" type="frame" src="' + image.src + '" /></v:shape>';				}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -