topical media & game development

talk show tell print

lib-present-graphic-svg-mouse-over-effects-files-ads-data-graphics.js / js



  (function(){var a;AdSenseGraphics.POS_TOP_LEFT_=0;AdSenseGraphics.POS_TOP_RIGHT_=1;AdSenseGraphics.POS_BOTTOM_LEFT_=2;AdSenseGraphics.POS_BOTTOM_RIGHT_=3;AdSenseGraphics.X_INTERCEPT_TOP_=0;AdSenseGraphics.X_INTERCEPT_BOTTOM_=1;AdSenseGraphics.Y_INTERCEPT_LEFT_=2;AdSenseGraphics.Y_INTERCEPT_RIGHT_=3;AdSenseGraphics.USER_AGENT_=navigator.userAgent;AdSenseGraphics.IS_OPERA_=typeof opera!="undefined";AdSenseGraphics.IS_IE_=!AdSenseGraphics.IS_OPERA_&&AdSenseGraphics.USER_AGENT_.indexOf("MSIE")!=-1;
  AdSenseGraphics.IS_SAFARI_=!AdSenseGraphics.IS_OPERA_&&AdSenseGraphics.USER_AGENT_.indexOf("Safari")!=-1;AdSenseGraphics.S_CURVE_CLASS_NAME_="curve";AdSenseGraphics.ROUNDED_CORNER_BG_CLASS_NAME_="rc_bg";AdSenseGraphics.ROUNDED_CORNER_BORDER_CLASS_NAME_="rc_border";AdSenseGraphics.SIGMOID_FUNCTION_WIDTH=12;AdSenseGraphics.SIGMOID_FUNCTION_OFFSET=6;function AdSenseGraphics(){}a=AdSenseGraphics.prototype;a.getPixelLeftX_=function(b){return b};a.getPixelRightX_=function(b){return b+1};
  a.getPixelBottomY_=function(b){return b};a.getPixelTopY_=function(b){return b+1};a.computeSigmoid_=function(b,d,c){b=12*b/d-6;return c/(1+Math.exp(b))};a.computeSigmoidInverse_=function(b,d,c){if(b<=0)return d;if(b>=c)return 0;b=b/c;b=Math.log((1-b)/b);return d*(b+6)/12};a.computeCircle_=function(b,d){b=Math.sqrt(Math.pow(d,2)-Math.pow(b,2));return isNaN(b)?0:b};
  a.addStyleRule_=function(b,d){if(AdSenseGraphics.IS_IE_)document.styleSheets[0].addRule(b,d);else{var c=document.createElement("style");c.type="text/css";var e=AdSenseGraphics.IS_SAFARI_?"innerText":"innerHTML";c[e]=b+"{"+d+"}";b=document.getElementsByTagName("head")[0];b.appendChild(c)}};
  a.createDiv_=function(b,d,c,e,f){var h=document.createElement("div"),j="position:absolute;overflow:hidden;left:";j+=b;j+="px;top:";j+=d;j+="px;width:";j+=c;j+="px;height:";j+=e;j+="px;";if(f!=null){j+="opacity:";j+=f;if(AdSenseGraphics.IS_IE_){j+=";filter: alpha(opacity=";j+=Math.round(f*100);j+=");"}}h.style.cssText=j;return h};
  a.getCirclePixelIntercepts_=function(b,d,c){var e=new Array(4);e[AdSenseGraphics.Y_INTERCEPT_LEFT_]=this.computeCircle_(this.getPixelLeftX_(b),c);e[AdSenseGraphics.Y_INTERCEPT_RIGHT_]=this.computeCircle_(this.getPixelRightX_(b),c);e[AdSenseGraphics.X_INTERCEPT_BOTTOM_]=this.computeCircle_(this.getPixelBottomY_(d),c);e[AdSenseGraphics.X_INTERCEPT_TOP_]=this.computeCircle_(this.getPixelTopY_(d),c);return e};
  a.getSigmoidPixelIntercepts_=function(b,d,c,e){var f=new Array(4);f[AdSenseGraphics.Y_INTERCEPT_LEFT_]=this.computeSigmoid_(this.getPixelLeftX_(b),c,e);f[AdSenseGraphics.Y_INTERCEPT_RIGHT_]=this.computeSigmoid_(this.getPixelRightX_(b),c,e);f[AdSenseGraphics.X_INTERCEPT_BOTTOM_]=this.computeSigmoidInverse_(this.getPixelBottomY_(d),c,e);f[AdSenseGraphics.X_INTERCEPT_TOP_]=this.computeSigmoidInverse_(this.getPixelTopY_(d),c,e);return f};
  a.getSigmoidAntiAliasOpacity_=function(b,d,c,e){c=this.getSigmoidPixelIntercepts_(b,d,c,e);b=this.getAntiAliasOpacity_(b,d,c);return b==-1?0:b};a.getCircleAntiAliasOpacity_=function(b,d,c,e){c=this.getCirclePixelIntercepts_(b,d,c);b=this.getAntiAliasOpacity_(b,d,c);if(b==-1)return 0;return e?1-b:b};
  a.getAntiAliasOpacity_=function(b,d,c){var e=0,f=new Array(2),h=new Array(2),j=false,m=false,g=false,n=false,k=this.getPixelBottomY_(d);d=this.getPixelTopY_(d);var l=this.getPixelLeftX_(b);b=this.getPixelRightX_(b);if(c[AdSenseGraphics.Y_INTERCEPT_LEFT_]>=k&&c[AdSenseGraphics.Y_INTERCEPT_LEFT_]<d){j=true;f[0]=0;h[0]=c[AdSenseGraphics.Y_INTERCEPT_LEFT_]-k}else if(c[AdSenseGraphics.X_INTERCEPT_TOP_]>=l&&c[AdSenseGraphics.X_INTERCEPT_TOP_]<b){m=true;f[0]=c[AdSenseGraphics.X_INTERCEPT_TOP_]-l;h[0]=1}if(!m&&
  !j)return-1;if(c[AdSenseGraphics.Y_INTERCEPT_RIGHT_]>=k&&c[AdSenseGraphics.Y_INTERCEPT_RIGHT_]<d){g=true;f[1]=1;h[1]=c[AdSenseGraphics.Y_INTERCEPT_RIGHT_]-k}else if(c[AdSenseGraphics.X_INTERCEPT_BOTTOM_]>=l&&c[AdSenseGraphics.X_INTERCEPT_BOTTOM_]<b){n=true;f[1]=c[AdSenseGraphics.X_INTERCEPT_BOTTOM_]-l;h[1]=0}if(j&&g){f=h[0]<=h[1]?h[0]:h[1];h=h[0]>h[1]?h[0]:h[1];e=f+(h-f)/2}else if(j&&n)e=h[0]*f[1]/2;else if(m&&g)e=1-(1-f[0])*(1-h[1])/2;else if(m&&n){h=f[0]<=f[1]?f[0]:f[1];f=f[0]>f[1]?f[0]:f[1];e=
  h+(f-h)/2}return e};
  a.createSigmoidCurve=function(b,d,c,e,f,h){this.addStyleRule_("#"+b.id+" ."+AdSenseGraphics.S_CURVE_CLASS_NAME_+" div","background-color: "+e);b.style.display="none";e=this.createDiv_(0,0,d,c);e.className=AdSenseGraphics.S_CURVE_CLASS_NAME_;for(var j,m=c-1,g,n,k,l=c-1,q=0;q<d;++q){j=m;m=Math.floor(this.computeSigmoid_(q+1,d,c));n=f?q:d-q;g=h?0:c-m;g=this.createDiv_(n,g,1,m);e.appendChild(g);for(var o=m;o<=j;++o){k=this.getSigmoidAntiAliasOpacity_(q,o,d,c);g=h?o:l-o;g=this.createDiv_(n,g,1,1,k);e.appendChild(g)}}b.appendChild(e);
  b.style.display=""};
  a.applyRoundedCorner=function(b,d,c,e,f,h,j,m){this.addStyleRule_("#"+b.id+" ."+AdSenseGraphics.ROUNDED_CORNER_BG_CLASS_NAME_+" div","background-color: "+e);this.addStyleRule_("#"+b.id+" ."+AdSenseGraphics.ROUNDED_CORNER_BORDER_CLASS_NAME_+" div","background-color: "+f);d+=h;c+=h;var g=b.style;g.display="none";b.innerHTML="";g.position="absolute";g.borderWidth="0px";g.backgroundColor="transparent";f=h+"px solid "+f;var n=m==AdSenseGraphics.POS_TOP_LEFT_||m==AdSenseGraphics.POS_BOTTOM_LEFT_;m=m==AdSenseGraphics.POS_TOP_LEFT_||
  m==AdSenseGraphics.POS_TOP_RIGHT_;var k=d-j;if(k>0){var l=n?d-k:0;k=this.createDiv_(l,0,k,c-h);l=k.style;l.backgroundColor=e;m?(l.borderTop=f):(l.borderBottom=f);b.appendChild(k)}k=c-j;if(k>0){l=m?c-k:0;k=this.createDiv_(0,l,d-h,k);l=k.style;l.backgroundColor=e;n?(l.borderLeft=f):(l.borderRight=f);b.appendChild(k)}this.createRoundedCorner_(b,d,c,j,h,n,m);g.display=""};
  a.createRoundedCorner_=function(b,d,c,e,f,h,j){var m=f>0;f=e-f;d=h?0:d-e;var g=j?0:c-e;c=this.createDiv_(d,g,e,e);c.className=AdSenseGraphics.ROUNDED_CORNER_BG_CLASS_NAME_;var n=this.createDiv_(d,g,e,e);n.className=m?AdSenseGraphics.ROUNDED_CORNER_BORDER_CLASS_NAME_:AdSenseGraphics.ROUNDED_CORNER_BG_CLASS_NAME_;for(var k=f,l=e,q=f,o=e,s,t,u=e-1,r=0;r<e;++r){d=h?u-r:r;k=q;l=o;q=Math.ceil(this.computeCircle_(r+1,f));o=Math.floor(this.computeCircle_(r+1,e));s=m?k:o;g=j?e-s:0;g=this.createDiv_(d,g,1,
  s);c.appendChild(g);for(var p=o;p<=l;++p){t=this.getCircleAntiAliasOpacity_(r,p,e,false);g=j?u-p:p;g=this.createDiv_(d,g,1,1,t);n.appendChild(g)}if(m){l=o-s;if(l>0){g=j?e-s-l:s;g=this.createDiv_(d,g,1,l);n.appendChild(g)}for(p=q-1;p<k;++p){t=this.getCircleAntiAliasOpacity_(r,p,f,true);g=j?u-p:p;g=this.createDiv_(d,g,1,1,t);n.appendChild(g)}}}b.appendChild(c);b.appendChild(n)};var asg=new AdSenseGraphics;if(typeof window.rcl!="undefined")for(var rc,i=0;i<rcl.length;i++){rc=rcl[i];asg.applyRoundedCorner(document.getElementById(rc[0]),rc[1],rc[2],rc[3],rc[4],rc[5],rc[6],rc[7])}typeof window.sc!="undefined"&&asg.createSigmoidCurve(document.getElementById(sc[0]),sc[1],sc[2],sc[3],sc[4],sc[5]);})()
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.