<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>2kno&#187; javascript</title>
	<atom:link href="http://2kno.com/norman/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://2kno.com/norman</link>
	<description>Norman Bringsjord</description>
	<lastBuildDate>Wed, 22 Sep 2010 00:58:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Adding Animation to a Logo</title>
		<link>http://2kno.com/norman/uncategorized/adding-animation-to-a-logo/</link>
		<comments>http://2kno.com/norman/uncategorized/adding-animation-to-a-logo/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 17:42:50 +0000</pubDate>
		<dc:creator>Norman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[DHTML]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[logo design]]></category>
		<category><![CDATA[web animation]]></category>

		<guid isPermaLink="false">http://2kno.com/norman/?p=268</guid>
		<description><![CDATA[  This is a logo I designed for a company that provides an email publishing web-based service.  The users create articles and maintain a mailing list of subscribers. Each subscriber is tagged as to what product lines they are interested in. The articles are also similarly tagged so that when it comes time to publish, [...]]]></description>
			<content:encoded><![CDATA[<p> </p>
<p><a href="http://2kno.com/norman/wp-content/uploads/2009/02/vrlogo.jpg" rel="lightbox[268]"><img class="alignleft size-full wp-image-385" title="vrlogo" src="http://2kno.com/norman/wp-content/uploads/2009/02/vrlogo.jpg" alt="vrlogo" width="125" height="100" /></a>This is a logo I designed for a company that provides an email publishing web-based service.  The users create articles and maintain a mailing list of subscribers. Each subscriber is tagged as to what product lines they are interested in. The articles are also similarly tagged so that when it comes time to publish, the subscribers only get information on those products they are interested in.</p>
<p>I wanted to make an animation that would take the place of those annoying splash  or intro screens that were a part of the old web. Everyone always looks for the &#8220;skip this intro&#8221; button anyway. I thought a brief animation on the actual page when it launches would be the best approach.</p>
<p>The thought I had in my head was emails coming out of the logo and spreading across the page as if they were being &#8220;sent out&#8221;. This seemed to be the simplest way of expressing what the service actually does without getting too didactic.  I had seen this movie<br />
<object width="425" height="344" data="http://www.youtube.com/v/wujD_LA0rK4&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/wujD_LA0rK4&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /></object></p>
<p>which may have been where I got the idea.  I didn&#8217;t really want to spend a lot of time on this since I have lots more work ahead of me in designing this website, but I really wanted to see this through. I started out with a sketch of how I thought best to go about starting to write the code.<br />
<img src="http://2kno.com/norman/vr/compassPoints.jpg" alt="" /></p>
<p> </p>
<p>Using  javascript I could change the position, size and transparency of the icons. The diagram I drew informed me that if I would live with only 8 possible compass points for direction of movement, I could really make this process simple. Here is the code:</p>
<pre><code>&lt;!--

var r012vals = new Array (-1,0,1);

function pageSetup() {
	setTimeout("startEnvelope('env01');",500);
	setTimeout("startEnvelope('env02');",650);
	setTimeout("startEnvelope('env03');",800);
	setTimeout("startEnvelope('env04');",900);
	setTimeout("startEnvelope('env05');",1000);
	setTimeout("startEnvelope('env06');",1200);
	setTimeout("startEnvelope('env07');",1250);
	setTimeout("startEnvelope('env08');",1400);
	setTimeout("startEnvelope('env09');",1500);
	setTimeout("startEnvelope('env10');",1650);
	setTimeout("startEnvelope('env11');",1800);
	setTimeout("startEnvelope('env12');",1900);
	}

function r012() {
	return r012vals[Math.floor(Math.random()*3)];
	}

function moveEnvelope(env,xf,yf,xPos,yPos,alph,size) {
	yp = yPos+"px";
	xp = xPos+"px";
	document.getElementById(env).style.top = yp;
	document.getElementById(env).style.left = xp;
	yPos = yPos + 3*yf;
	xPos = xPos + 3*xf;
	if (size &gt; 0) { size ; }
	sz = size+"px";
	document.getElementById(env).style.width = sz;
	if (alph &lt; 199) {
		alph++;
		setOpacity(env,alph);
		setTimeout(function(){moveEnvelope(env,xf,yf,xPos,yPos,alph,size);},10);
		}
	}

function startEnvelope(ex) {
	xf = r012();
	yf = r012();
	if (xf==0 &amp;#038;&amp; yf==0) { yf = 1; }
	xPos = 100;
	yPos = 20;
	alph = 0;
	size = 140;
	env = ex;
	document.getElementById(env).style.visibility = "visible";
	moveEnvelope(env,xf,yf,xPos,yPos,alph,size);
	}

function setOpacity(myOBJ,opac) {
	var tOBJ = document.getElementById(myOBJ).style;
	if (opac &gt; 100) { opac = 100 - (opac - 100); }
	opac = (opac == 100)?99.999:opac;		// IE/Win
	tOBJ.filter = "alpha(opacity:"+opac+")";	// Safari&lt;1.2, Konqueror
	tOBJ.KHTMLOpacity = opac/100;			// Older Mozilla and Firefox
	tOBJ.MozOpacity = opac/100;			// Safari 1.2, newer Firefox and Mozilla, CSS3
	tOBJ.opacity = opac/100;
	}

//--&gt;</code></pre>
<p>The first thing was to look at how to make the animation random every time the page loads. If you look at my diagram, you will see that a vector can be described in terms of three numbers which are -1, 0 and +1.  I established an array with these three numbers and created a random number generator that would give me a random number between 0 and 2 to select one item in the array. Only one problem. There is a case where it will generate two zeros. There is no vector for two zeros so I had to have a line of code to check for that. Quick and dirty fix on that was just to make the y vector a 1 in that case. Not perfect, but it works. The rest is fairly straightforward and makes something that looks like this in a screen capture:<img src="http://2kno.com/norman/vr/screenShot.jpg" alt="" /> and for the full effect, you can <a href="http://vr.2kno.com/demo.php" onclick="pageTracker._trackPageview('/outgoing/vr.2kno.com/demo.php?referer=');">click here</a> and watch it in motion. Mouseover the logo and it will do another random effect.</p>
]]></content:encoded>
			<wfw:commentRss>http://2kno.com/norman/uncategorized/adding-animation-to-a-logo/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

