<?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>Scott builds Software &#187; Javascript</title>
	<atom:link href="http://scottpenberthy.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://scottpenberthy.com</link>
	<description>Musings on iPhone, Flash and the Cloud</description>
	<lastBuildDate>Wed, 08 Sep 2010 17:20:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Animated GIFs and video thumbnails from YouTube</title>
		<link>http://scottpenberthy.com/2009/10/08/animated-gifs-and-video-thumbnails-from-youtube/</link>
		<comments>http://scottpenberthy.com/2009/10/08/animated-gifs-and-video-thumbnails-from-youtube/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 14:35:21 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Youtube Animated GIFs]]></category>
		<category><![CDATA[Youtube video thumbnails]]></category>

		<guid isPermaLink="false">http://scottpenberthy.com/?p=336</guid>
		<description><![CDATA[Scott updates a free App for converting Youtube videos to animated GIFs, video thumbnails and MP3 clips.]]></description>
			<content:encoded><![CDATA[<div class="wp-caption alignright" style="width: 220px"><a href="http://scottpenberthy.com/tc"><img alt="Kanye West disses Taylor Swift" src="http://scottpenberthy.com/tc/videos/ZvaSaeFMCy8/clips/3b66f35b/image.gif" title="Kanye West and Taylor Swift" width="176" height="132" /></a><p class="wp-caption-text">Kanye West disses Taylor Swift<br/><a href='http://www.youtube.com/watch?v=ZvaSaeFMCy8'>source video</a></p></div>
<div class="wp-caption alignleft" style="width: 310px"><br />
<embed src="http://scottpenberthy.com/swf/thumb.swf" quality="high" bgcolor="#ffffff" width="212" height="152" name="thumb" flashvars="flv=http://scottpenberthy.com/tc/videos/5sBLir8H2zM/clips/a04ade94/video.flv&#038;cue=http://scottpenberthy.com/tc/videos/5sBLir8H2zM/frames/33.jpg" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" /><br />
<p class="wp-caption-text">Edge: The Sound in my Head (click image to play)<br /><a href='http://www.youtube.com/watch?v=5sBLir8H2zM&#038;feature=player_embedded'>source video</a></p></div>
<p><br clear="both"></p>
<p>In 2008 Fitim Blaku and I were playing around with ideas for manipulating video.  Over a weekend I threw together a little site, tubechopper.com, for extracting animated GIFs, MP3 clips, and video thumbnails from a YouTube video.  Its a fun hack with <a href="http://curl.haxx.se/">curl</a>, <a href="http://ffmpeg.org/">ffmpeg</a>, <a href="http://www.imagemagick.org/script/index.php">Image Magick</a>, a <a href="http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/">JavaScript image cropper</a>, and some jQuery dance steps.</p>
<p>Youtube later changed their techniques for publishing videos, which broke TubeChopper.  I took it down.</p>
<p>Recently I saw that <a href="http://gifsoup.com">GifSoup</a> began to get some traction on exactly the same idea.  Argh.  Don&#8217;t you hate it when that happens?  I hand it to those guys, though, for good marketing, getting coverage in CNet, and adding the gallery for sharing videos.  Google Adwords cover the site to extract what they can for their work. Nice touch.</p>
<p>For yuks I dusted off the code, fixed the Youtube scrapery, and posted the <a href="http://scottpenberthy.com/tc/">animated GIF Youtube converter</a> to this blog.  The code respects Youtube video providers who&#8217;ve asked that their videos be protected.</p>
]]></content:encoded>
			<wfw:commentRss>http://scottpenberthy.com/2009/10/08/animated-gifs-and-video-thumbnails-from-youtube/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>&quot;Photobooth&quot; Images in Flash and JavaScript</title>
		<link>http://scottpenberthy.com/2009/01/24/photobooth-images-in-flash-and-javascript/</link>
		<comments>http://scottpenberthy.com/2009/01/24/photobooth-images-in-flash-and-javascript/#comments</comments>
		<pubDate>Sat, 24 Jan 2009 10:58:48 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[photobooth]]></category>

		<guid isPermaLink="false">http://scottpenberthy.com/?p=160</guid>
		<description><![CDATA[I've been working on a handy utility in Flash and JavaScript that will let you morph images, videos, and webcams like Photobooth.  Each effect is specified as a "preset" specified as a text string or external file.  No Flash programming required.]]></description>
			<content:encoded><![CDATA[<div style="text-align:center">
<div style="float:right">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="216" height="270" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="name" value="TestDriver" /><param name="bgcolor" value="#869ca7" /><param name="align" value="middle" /><param name="src" value="http://scottpenberthy.com/meshdemo/TestDriver.swf" /><embed type="application/x-shockwave-flash" width="216" height="270" src="http://scottpenberthy.com/meshdemo/TestDriver.swf" align="middle" bgcolor="#869ca7" name="TestDriver"></embed></object></p>
<p>Photoboothed with &#8220;presets&#8221;</p>
</div>
<div style="float:left">
<img src="http://scottpenberthy.com/meshdemo/obama.jpg"></p>
<p>Source image</p>
</div>
</div>
<p><br clear="both"/></p>
<p>My kids love to play with Photobooth on the Mac.  The fish eye, pinch, punch, squeeze, Andy Warhol, and other looks provide countless sources of fun and amusement.</p>
<p>I&#8217;ve been working on a handy utility in Flash that will let you morph images, videos, and webcams like Photobooth.  Each effect is specified as a &#8220;preset.&#8221;  A preset is a set of mathematical constraints and parameter values specified in an external character string, often stored in a file.  I think the idea was first used in the Milkdrop music visualizer in the late 90&#8217;s.  I&#8217;m not sure.</p>
<p>Anyway, I&#8217;ve written a preset compiler in Flash that turns these equations into bytecodes for a custom, finely tuned virtual machine.  The virtual machine operates much like an HP calculator, a stack machine with numerous functions.</p>
<p>I then created a 2d mesh and exposed several values at each vertex.  Each of these values can be manipulated by the presets.  They include the texture location (u,v), the screen location (x,y), rotation (rot), scaling (sx,sy), translation (dx,dy), a nonlinear zoom (zoom, zoom_exp), and a sinusoidal warping technique (warp, warp_exp, warp_scale).  You can also specify the &#8220;current&#8221; values of (u,v) as (u_t,v_t).  I also cache the polar coordinates of the vertex as (ang,rad).  These names are borrowed from Milkdrop&#8230;</p>
<p>Finally, I wrapped it all together by placing the 2d mesh on a sprite, loading a preset, then running it every frame, at every vertex.  For fun I pass along the current time as a &#8220;time&#8221; value.</p>
<p>Here are some simple presets.  The first one is a fisheye effect, repeating the ImageMagick trick in Flash.</p>
<pre lang="c">rs=pow(rad,2.5)/2;
u=2+time*0.5-rs*cos(ang);
v=2+time*0.5-rs*sin(ang);
u_t=u;
v_t=v;</pre>
<p>This next preset will gradually shrink the source image over time.  Once it shrinks, Flash wraps around and fills the empty space as one would expect on a graphics card:</p>
<pre lang="c">sx=1.0-time/4;
sy=1.0-time/4</pre>
<p>I was playing with Zoom a bit here.  This neat effect appears to stretch the image like taffy from the center, oscillating back and forth in time:</p>
<pre lang="c">zoom=max(1,1.0+sin(time*0.31415)*rad)</pre>
<p>Another trick with the zoom exponent, one that also oscillates:</p>
<pre lang="c">where=sin(time*3.1415);
zoom=1.0+2*rad;
zoom_exp=1.0+where*0.5;</pre>
<p>This is a mashup effect that shifts, rotates, and zooms over time in a variety of ways:</p>
<pre lang="c">dx=sin(time);
dy=cos(time);
rot=time*1.57;
zoom=1.0-0.8*sin(time*2.675);
zoom_exp=3</pre>
<p>In the end, I use the identity function to map the current (u_t,v_t) to the original (u,v)</p>
<pre lang="c">u_t=u;
v_t=v</pre>
<p>Soon I plan to release the code.  You&#8217;ll use JavaScript to specify the preset and source image, video or webcam.  Flash will do all the math.  Voila!  Photobooth in Flash and JavaScript (well, almost).  Suggestions welcome!</p>
]]></content:encoded>
			<wfw:commentRss>http://scottpenberthy.com/2009/01/24/photobooth-images-in-flash-and-javascript/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Conditional CSS (almost)</title>
		<link>http://scottpenberthy.com/2008/12/03/conditional-css-almost/</link>
		<comments>http://scottpenberthy.com/2008/12/03/conditional-css-almost/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 16:31:47 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://scottpenberthy.com/?p=144</guid>
		<description><![CDATA[Today I was hacking IE7, working on formatting issues caused by relative positioning in CSS.  IE7 likes to ignore the negative X positions (e.g. left: -87).   While Googling around I stumbled across an elegant hack from Rafael Lima that let&#8217;s me specify different CSS depending on the browser.
Add their one line of JavaScript to your [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was hacking IE7, working on formatting issues caused by relative positioning in CSS.  IE7 likes to ignore the negative X positions (e.g. left: -87).   While Googling around I stumbled across an elegant hack from <a href="http://rafael.adm.br/css_browser_selector">Rafael Lima</a> that let&#8217;s me specify different CSS depending on the browser.</p>
<p>Add their one line of JavaScript to your global JavaScript file, then use a class selector to specify different CSS options based on the browser.  Here&#8217;s an example in CSS that will change the color of a rectangle based on the browser you&#8217;re using.  Brilliant!</p>
<pre lang="css">
.ie .example {
  background-color: yellow
}
.ie7 .example {
  background-color: orange
}
.gecko .example {
  background-color: gray
}
.win.gecko .example {
  background-color: red
}
.linux.gecko .example {
  background-color: pink
}
.opera .example {
  background-color: green
}
.konqueror .example {
  background-color: blue
}
.webkit .example {
  background-color: black
}
.example {
  width: 100px;
  height: 100px;
}
.no_js { display: block }
.has_js { display: none }
.js .no_js { display: none }
.js .has_js { display: block }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://scottpenberthy.com/2008/12/03/conditional-css-almost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
