<?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>Flying memes &#187; Interfaccie</title>
	<atom:link href="http://sandropaganotti.com/categoria/interfaccia/feed/" rel="self" type="application/rss+xml" />
	<link>http://sandropaganotti.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 08 Jan 2012 16:00:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Real time twitter data visualization with Processing.js</title>
		<link>http://sandropaganotti.com/2011/10/25/real-time-twitter-data-visualization-with-processing-j/</link>
		<comments>http://sandropaganotti.com/2011/10/25/real-time-twitter-data-visualization-with-processing-j/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 22:30:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Annunci]]></category>
		<category><![CDATA[Interfaccie]]></category>
		<category><![CDATA[data visualization]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[real time]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=553</guid>
		<description><![CDATA[Lately I&#8217;ve been pretty busy enjoying some real time data visualization examples and demo. To have some data to work with I decided to use Twitter API, in particular I rely on jQuery LiveTwitter plugin by elektronaut; next I built a stack chart like visualization in which every new tweet of a chosen topic is [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been pretty busy enjoying some real time data visualization examples and demo. To have some data to work with I decided to use Twitter API, in particular I rely on <a href="http://elektronaut.github.com/jquery.livetwitter/" target="_blank">jQuery LiveTwitter plugin</a> by elektronaut; next I built a stack chart like visualization in which every new tweet of a chosen topic is dropped over its language column.</p>
<p><span id="more-553"></span></p>
<p style="text-align: left;">To create the view I used Processing.js, which is very easy and simple to work with. Here&#8217;s a screenshot of the completed application:</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-554" title="processing js real time infographic" src="http://sandropaganotti.com/wp-content/uploads/2011/10/ishot-586.png" alt="" width="600" height="358" /></p>
<p style="text-align: left;">The application is also featured in Processing.js <a href="http://processingjs.org/exhibition" target="_blank">exhibition page</a> and a <a href="http://javascript.html.it/guide/leggi/216/canvas-guida-pratica/" target="_blank">guide (in italian)</a> is undergoing with all the technical details about its implementation.</p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2011/10/25/real-time-twitter-data-visualization-with-processing-j/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the :required pseudo selector to enhance forms</title>
		<link>http://sandropaganotti.com/2011/08/14/using-the-required-pseudo-selector-to-enhance-forms/</link>
		<comments>http://sandropaganotti.com/2011/08/14/using-the-required-pseudo-selector-to-enhance-forms/#comments</comments>
		<pubDate>Sun, 14 Aug 2011 11:29:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Interfaccie]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[required]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=542</guid>
		<description><![CDATA[Lately I come up with this idea on how to enhance a form by using the :required pseudo element. What you can do is mix this new pseudo element with the &#8216;+&#8217; selector in order to modify elements that are adjacent to your input tag, such as the label. Here&#8217;s an example: input:required + label:after [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I come up with this idea on how to enhance a form by using the <a href="http://www.w3.org/TR/css3-ui/#pseudo-required-value">:required</a> pseudo element. What you can do is mix this new pseudo element with the <a href="http://www.w3schools.com/cssref/sel_element_pluss.asp">&#8216;+&#8217;</a> selector in order to modify elements that are adjacent to your input tag, such as the label.</p>
<p><span id="more-542"></span>Here&#8217;s an example:</p>
<pre><code class="css">
input:required + label:after {
  content: ' *';
  color: black;
}
</code></pre>
<p>By this way you are able to dynamically append the classic &#8216;*&#8217; to the labels that belongs to input tags with the required flag. Obviously you have to put the label after the input tag but then you can revert this structure by using some CSS float instructions.</p>
<p>Here&#8217;s the running example:</p>
<p><iframe style="width: 100%; height: 300px;" src="http://jsfiddle.net/sandro_paganotti/9tyhz/3/embedded/css,html,result" width="320" height="240"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2011/08/14/using-the-required-pseudo-selector-to-enhance-forms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A pure CSS3 coverflow effect for Chrome, Firefox and Safari</title>
		<link>http://sandropaganotti.com/2011/08/05/a-pure-css3-coverflow-effect-for-chrome-firefox-and-safari/</link>
		<comments>http://sandropaganotti.com/2011/08/05/a-pure-css3-coverflow-effect-for-chrome-firefox-and-safari/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 22:23:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Interfaccie]]></category>
		<category><![CDATA[coverflow]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[transform]]></category>
		<category><![CDATA[transition]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=516</guid>
		<description><![CDATA[I&#8217;ve been recently playing with some of the newest CSS3 features, such as pseudoclasses selectors, transition and transform properties and attr(). In order to have something concrete on which test these features  I created a coverflow effect that works only out of CSS instructions without the use of javascript. I used some of the amazing [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been recently playing with some of the newest CSS3 features, such as <a href="http://www.w3.org/TR/css3-selectors/" target="_blank">pseudoclasses selectors</a>, <a href="http://www.w3.org/TR/css3-transitions/" target="_blank">transition</a> and <a href="http://dev.w3.org/csswg/css3-3d-transforms/" target="_blank">transform</a> properties and <a href="http://www.w3.org/TR/css3-values/#attribute" target="_blank">attr()</a>. In order to have something concrete on which test these features  I created <a href="http://sandropaganotti.com/wp-content/goodies/demos/cards/index.html#aela" target="_blank">a coverflow effect that works only out of CSS instructions without the use of javascript</a>.</p>
<p><span id="more-516"></span><br />
I used some of the amazing CSS 3D transformations to archieve this effect under WebKit based browsers. Here&#8217;s a snippet from the page:</p>
<pre><code class="css"> 
  #container{
     margin: 0 auto;
     width: 100%;
     height: 90%;
     max-width: 1024px;
     -webkit-transform-style: preserve-3d;
     -webkit-perspective: 900;
     -webkit-perspective-origin: 100% 30%;
  }
</code></pre>
<p>The container, which is the div that hold the rest of the elements, has some <a href="http://www.webkit.org/blog/386/3d-transforms/" target="_blank">-webkit-*</a> experimental properties that set the position and the distance of the point of view of the user from the scene, as much as it happens with 3D software.</p>
<p>After this each card needs to be rotated against its Y axes; here comes to rescue another CSS3 property:</p>
<pre><code class="css">
  .card{
     -webkit-transform: rotateY( 120deg);
  }
</code></pre>
<p>Then, all you need is find a way to trigger a change of CSS properties in your .card elements while specifying a transition which handles this change smoothly. So first let&#8217;s add this transition:</p>
<pre><code class="css">
  .card{
     -webkit-transition: all 1s ease-out;
  }
</code></pre>
<p>And then let&#8217;s use the :target pseudoclass which gets applied to an &lt;a&gt; element when its name became part of the URL (either because clicked or typed):</p>
<pre><code class="css">
  .card:target{
    -webkit-transform: rotateY( 0deg);
  }
</code></pre>
<p><img src="http://sandropaganotti.com/wp-content/uploads/2011/08/ishot-516-1024x601.png" alt="" title="ishot-516" width="600" class="aligncenter size-large wp-image-535" /></p>
<p>The trickiest part is then try to make this thing works also under Firefox which doesn&#8217;t have 3D transformations. It turns out that you can emulate them by using wisely the skew(xdeg, ydeg) transform, so you can do the following:</p>
<pre><code class="css">
  .card{
     -moz-transform: skew(0deg,-35deg) scale(0.70);
  }
  .card:target{
     -moz-transform: skew(0deg,0deg) scale(1);
  }
</code></pre>
<p>Good, but now there&#8217;s another challenge: how to solve this ?</p>
<p><img src="http://sandropaganotti.com/wp-content/uploads/2011/08/ishot-513-1024x611.png" alt="" title="ishot-513" width="600" class="aligncenter size-large wp-image-526" /></p>
<p>The elements on the right side of the selected one have two issues: they should be inclined on the opposite angle and the way they overlap each other should also be reversed. </p>
<p>To solve the first part we can rely on the <a href="http://w3schools.com/cssref/sel_gen_sibling.asp" target="_blank">~ selector</a> to tell the browser that each element following the selected one must obey to a different skew angle:</p>
<pre><code class="css">
  .card:target ~ .card{
    -moz-transform: skew(0deg,20deg) scale(0.70);
  }
</code></pre>
<p><img src="http://sandropaganotti.com/wp-content/uploads/2011/08/ishot-514-1024x611.png" alt="" title="ishot-514" width="600" class="aligncenter size-large wp-image-529" /></p>
<p>The only solution I found to archive the second issue is to use the <a href="http://w3schools.com/cssref/sel_element_pluss.asp" target="_blank">+ selector</a> iteratively in order to assign a z-index to an element based on its distance from the selected one: </p>
<pre><code class="css">
  .card:target + .card{
    z-index: 10;
  }

  .card:target + .card + .card{
    z-index: 9;
  }

  .card:target + .card + .card + .card {
    z-index: 8;
  }

  .card:target + .card + .card + .card + .card{
    z-index: 7;
  }

  .card:target + .card + .card + .card + .card + .card{
    z-index: 6;
  }

  .card:target + .card + .card + .card + .card + .card + .card{
    z-index: 5;
  }

  .card:target + .card + .card + .card + .card + .card + .card + .card{
    z-index: 4;
  }

  .card:target + .card + .card + .card + .card + .card + .card + .card + .card{
    z-index: 3;
  }

  .card:target + .card + .card + .card + .card + .card + .card + .card + .card + .card{
    z-index: 2;
  }

  .card:target + .card + .card + .card + .card + .card + .card + .card + .card + .card + .card{
    z-index: 1;
  }
</code></pre>
<p>Here&#8217;s the final result:<br />
<img src="http://sandropaganotti.com/wp-content/uploads/2011/08/ishot-515-1024x611.png" alt="" title="ishot-515" width="600" class="aligncenter size-large wp-image-532" /></p>
<p>You can have a working demo at this address:<br />
<a href="http://sandropaganotti.com/wp-content/goodies/demos/cards/index.html#aela" target="_blank">http://sandropaganotti.com/wp-content/goodies/demos/cards/index.html#aela</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2011/08/05/a-pure-css3-coverflow-effect-for-chrome-firefox-and-safari/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing with media queries</title>
		<link>http://sandropaganotti.com/2011/07/09/playing-with-media-queries/</link>
		<comments>http://sandropaganotti.com/2011/07/09/playing-with-media-queries/#comments</comments>
		<pubDate>Sat, 09 Jul 2011 01:10:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Interfaccie]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=503</guid>
		<description><![CDATA[I recently created a small website called &#8216;La piccola biblioteca della natura&#8217; to showcase some of my girlfriend watercolors. I decided to go for a responsive design and set up some nice media-query statements. If you try to resize the browser window you surely notice how the structure of the fruits change in response to [...]]]></description>
			<content:encoded><![CDATA[<p>I recently created a small website called <a href="http://piccolabiblioteca.nijiart.it/" target="_blank">&#8216;La piccola biblioteca della natura&#8217;</a> to showcase some of my <a href="http://nijiart.it/" target="_blank">girlfriend</a> watercolors. I decided to go for a responsive design and set up some nice media-query statements. If you try to resize the browser window you surely notice how the structure of the fruits change in response to this operation.</p>
<p><span id="more-503"></span></p>
<p>&nbsp;</p>
<p style="text-align: center;"><img class="aligncenter size-large wp-image-507" title="ishot-460" src="http://sandropaganotti.com/wp-content/uploads/2011/07/ishot-4601-1024x717.png" alt="" width="614" height="430" /></p>
<p>To archive this result I played a bit with clear and float properties by adding them to some specific elements, here&#8217;s a sample:</p>
<p>The .cestello HTML structure:</p>
<pre>&lt;div class="cestello"&gt;
    &lt;div&gt;
        &lt;a href="#arancia" onclick="PB.to('#arancia');return false;"&gt;
            &lt;img src="img/arancia-small.png" alt="arancia"&gt;
        &lt;/a&gt;
    &lt;/div&gt;
    &lt;div&gt;
        &lt;a href="#banana" onclick="PB.to('#banana');return false;"&gt;
            &lt;img src="img/banana-small.png" alt="banana"&gt;
        &lt;/a&gt;
    &lt;/div&gt;
    &lt;!-- other divs --&gt;
&lt;/div&gt;</pre>
<p>And the corresponding CSS code:</p>
<pre>.cestello{
  float:left;
  width: 100%;
}

@media screen and (min-width:480px) and (max-width:960px){
  .cestello div{
     width: 33%;
  }
  .cestello div:nth-of-type(3){
    clear: right;
  }
  .cestello div:nth-of-type(4){
    clear: left;
  }
}

@media screen and (max-width:480px){
  .cestello{
    float:none;
    width: 80%;
    margin-left: auto;
    margin-right: auto;
  }

  .cestello div{
     width: 50%;
  }
  .cestello div:nth-of-type(even){
    clear: right;
  }
  .cestello div:nth-of-type(odd){
    clear: left;
  }
}</pre>
<p>Here you find the three statuses in which the &#8216;.cestello&#8217; structure may be found. By using some clever CSS3 selector I&#8217;m able to inject &#8216;clear:right&#8217; and &#8216;clear:left&#8217; and change the aspect of the page.</p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2011/07/09/playing-with-media-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 Video Mosaic: a proof of concept</title>
		<link>http://sandropaganotti.com/2011/03/20/html5-video-mosaic-a-proof-of-concept/</link>
		<comments>http://sandropaganotti.com/2011/03/20/html5-video-mosaic-a-proof-of-concept/#comments</comments>
		<pubDate>Sun, 20 Mar 2011 10:54:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Interfaccie]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[video mosaic]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=474</guid>
		<description><![CDATA[Following a suggestion by a VJ friend of mine I worked on creating a real time HTML5 video mosaic that can be used to aggregate videos from your hard disk in a custom-size grid. To accomplish that I set-up a two-page structure: a dashboard, used to choose which files to play and to control the [...]]]></description>
			<content:encoded><![CDATA[<p>Following a suggestion by a <a title="Joe Ferrari on linkedIn" href="http://www.linkedin.com/pub/joe-ferrari/7/91a/961" target="_blank">VJ friend of mine</a> I worked on creating a real time HTML5 video mosaic that can be used to aggregate videos from your hard disk in a custom-size grid.</p>
<p><span id="more-474"></span>To accomplish that I set-up a two-page structure: a dashboard, used to choose which files to play and to control the grid size (other controls may came next), and the mosaic page itself: in this way one page can be projected in full-screen while the other one can be viewed on the second monitor.</p>
<p>In the dashboard lays a drop-area where video files can be dropped, dropping one or more file cause afunction &#8216;caricaIlVideo&#8217; to be called:</p>
<pre><code class="javascript">caricaIlVideo = function(evento){
  var files = evento.dataTransfer.files;
  for(var x=0; x &lt; files.length; x++){
    console.log("wooo");
    worker.port.postMessage("comando-verso-mosaic:carica-video:" +
      window.webkitURL.createObjectURL(files[x]));
  }
}
</code></pre>
<p>The function uses Drag And Drop API and File API to recover the dropped files, then a message is sent to a SharedWebWorker for each of the dropped files containing a string like :</p>
<pre><code class="javascript">"comando-verso-mosaic:carica-video:blob:http://sandropaganotti.com/ecba59ec-d1cc-435c-9bd3-ba50e2bf0eab"
</code></pre>
<p>the blob* part is the most interesting: it contains the URL of the File dropped. The SharedWebWorker then unfold the message removing the &#8216;comando-verso-mosaic&#8217; part and sends the rest to the mosaic page.</p>
<p>When the mosaic page receives a message like this it launch a function called &#8216;caricaVideo&#8217;:</p>
<pre><code class="javascript">caricaVideo = function(blob_url){
  var video  = document.createElement('video');
  var source = document.createElement('source');
  video.muted = true;
  video.volume = 0.0;
  video.loop  = true;
  source.src = blob_url;
  source.type= "video/webm";
  video.appendChild(source);
  document.querySelector("#videos").appendChild(video);
  video.addEventListener('canplaythrough', iniziaLaProiezione, false);
}
</code></pre>
<p>The function basically creates a new video element using the blob URL as a source and then attach to the element a listener for the &#8216;canplaythrough&#8217; event, which occurs when the video buffer reach enough capacity to guarantee a full-play performance.</p>
<p>The mosaic has a looping function, called &#8216;aggregaVideo&#8217; which takes care of the drawing stuff: it iterates over all the video elements created and it draws them over a canvas according with the tessellation configuration:</p>
<pre><code class="javascript">aggregaVideo = function(canvas_context, videoboxes){
    canvas_context.canvas.width = canvas_context.canvas.width;
    for(var i=0; i &lt; tassello['tassellazione-y']; i++){
      for(var k=0; k &lt; tassello['tassellazione-x']; k++){
        if(videoboxes[k + i*tassello['tassellazione-y']] != undefined){
          canvas_context.drawImage(videoboxes[k + i*tassello['tassellazione-y']],
            tassello.width * k, tassello.height * i,
            tassello.width , tassello.height
          );
        }
      }
    }
    setTimeout(function(){aggregaVideo(canvas_context,  document.querySelectorAll('#videos video'))},0);
}</code></pre>
<p>Here&#8217;s a video showing the whole thing running:</p>
<p><iframe title="YouTube video player" width="640" height="390" src="http://www.youtube.com/embed/owww1nssLHc?rel=0" frameborder="0" allowfullscreen></iframe></p>
<p>The code of this project is, as usual, <a href="https://github.com/sandropaganotti/html5-video-mosaic">on my github account</a>. </p>
<p>Finally you can test the video mosaic by yourself launching both the <a href="http://sandropaganotti.com/wp-content/goodies/demos/HTML5/html5-video-mosaic/dashboard.html">dashboard</a> and the <a href="http://sandropaganotti.com/wp-content/goodies/demos/HTML5/html5-video-mosaic/mosaic.html">mosaic</a>; be sure to have some webm video files on your computer, you can find some here:  <a href="http://www.webmfiles.org/demo-files/">http://www.webmfiles.org/demo-files/</a> or you can convert some using <a href="http://www.mirovideoconverter.com/">miro video converter</a>. Please note that everything should work, at the moment, only on Chrome 10.</p>
<p>Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2011/03/20/html5-video-mosaic-a-proof-of-concept/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A mouse driven CSS3 &#8216;rotate3d&#8217; parallax gallery for Safari</title>
		<link>http://sandropaganotti.com/2010/09/09/a-mouse-driven-css3-rotate3d-parallax-gallery-for-safari/</link>
		<comments>http://sandropaganotti.com/2010/09/09/a-mouse-driven-css3-rotate3d-parallax-gallery-for-safari/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 22:33:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Interfaccie]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[parallax]]></category>
		<category><![CDATA[rotate3d]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=437</guid>
		<description><![CDATA[I&#8217;m recently enjoying KillZone 2 so much; during one of my gaming sessions I noticed that the loading screen is designed as a bas-relief that you can partially rotate using the joypad oscilloscope, this technique, although easy to implement in a PS3 game, produce a very interesting effect and so I decided to try to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m recently enjoying <a href="http://en.wikipedia.org/wiki/Killzone_2" target="_blank">KillZone 2</a> so much; during one of my gaming sessions I noticed that the loading screen is designed as a bas-relief that you can partially rotate using the joypad oscilloscope, this technique, although easy to implement in a PS3 game, produce a very interesting effect and so I decided to try to transpose it to a web gallery.</p>
<p><span id="more-437"></span></p>
<p>To archive such effect I used CSS3 3d properties, in particular the &#8216;<a href="http://developer.apple.com/library/safari/#documentation/appleapplications/reference/SafariCSSRef/Articles/Functions.html#//apple_ref/doc/uid/TP40007955-SW16" target="_blank">rotate3d</a>&#8216; one; here&#8217;s the portion of html used to define the picture: three divs have been used as layers with &#8216;preserve3d&#8217; and &#8216;translateZ&#8217; to specify the distance between each of them:</p>
<pre><code class="javascript">&lt;div style="position: absolute; top: 50%; left:50%; margin-left: -350px; margin-top: -233px;
            -webkit-perspective: 1000;" &gt;
  &lt;div id="picture" style="height: 466px;
          width: 699px;
          -webkit-transform-style: preserve-3d;
          background: url('flowers.png') no-repeat;
          "&gt;
          &lt;div style="width: 377px;
                height: 424px; background: url('body.png') no-repeat;
                position: absolute;
                -webkit-transform: translateZ(20px);
                top: 45px; left: 75px;"&gt;
          &lt;/div&gt;
          &lt;div style="position: absolute;
          -webkit-transform: translateZ(30px);
          bottom: 0px; right: 0px; padding-left: 30px; padding-right: 30px;
          background: rgba(0,0,0,0.6);     font-family: 'Lobster', arial, serif;
          color: #FFF; font-size: 30px; line-height: 60px; text-align:center;"&gt;
            Francy taking pictures
          &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</code></pre>
<p>Next I wrote a small JQuery flavored Javascript to rotate the &#8216;layer0&#8242; div according to mouse position; the other two divs follows the rotation of the first automatically preserving the 3D spatial relations.</p>
<pre><code class="javascript">$(document).ready(function() {
    $('body').mousemove(function(event) {
        cx = Math.ceil($('body').width() / 2.0);
        cy = Math.ceil($('body').height() / 2.0);
        dx = event.pageX - cx;
        dy = event.pageY - cy;

        tiltx = (dy / cy);
        tilty = - (dx / cx);
        radius = Math.sqrt(Math.pow(tiltx,2) + Math.pow(tilty,2));
        degree = (radius * 20);

        $('#picture').css('-webkit-transform','rotate3d(' + tiltx + ', ' + tilty + ', 0, ' + degree + 'deg)');
    });
});
</code></pre>
<p>And that&#8217;s all; you can try the demo at this link: <a href="http://sandropaganotti.com/wp-content/goodies/demos/wow-parallax/parallax-gallery.html" target="_blank">Parallax Gallery</a>, please note <strong>that only works on Safari</strong>; here&#8217;s a screenshot of the effect in action:</p>
<p><a href="http://sandropaganotti.com/wp-content/goodies/demos/wow-parallax/parallax-gallery.html" target="_blank"><img class="aligncenter size-full wp-image-439" title="Francy taking pictures" src="http://sandropaganotti.com/wp-content/uploads/2010/09/ishot-2401.png" alt="" width="600" height="472" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2010/09/09/a-mouse-driven-css3-rotate3d-parallax-gallery-for-safari/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>We Love Shadows! A CSS3 and Javascript based light source</title>
		<link>http://sandropaganotti.com/2010/06/19/we-love-shadows-a-css3-and-javascript-based-light-source/</link>
		<comments>http://sandropaganotti.com/2010/06/19/we-love-shadows-a-css3-and-javascript-based-light-source/#comments</comments>
		<pubDate>Sat, 19 Jun 2010 13:31:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Interfaccie]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=405</guid>
		<description><![CDATA[CSS3 has gradients and CSS3 has shadows, so why don&#8217;t try to use both to simulate a light source ? That is the basic idea behind this project. I&#8217;ve set-up a small demo which let you use the mouse to direct a light source over a text and observe its shadow change according to light [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://dev.w3.org/csswg/css3-images/" target="_blank">CSS3 has gradients</a> and <a href="http://www.w3.org/TR/css3-text/#text-shadow" target="_blank">CSS3 has shadows</a>, so why don&#8217;t try to use both to simulate a light source ? That is the basic idea behind this project. <a href="http://sandropaganotti.com/wp-content/goodies/demos/we-love-shadows/we-love-shadows.html" target="_blank">I&#8217;ve set-up a small demo</a> which let you use the mouse to direct a light source over a text and observe its shadow change according to light position.</p>
<p><span id="more-405"></span> To simulate the light behavior I used a CSS3 gradient on the body background and a text-shadow property on the text. Both of these css3 attributes are then dynamically changed upon the user&#8217;s mouse move.</p>
<p>Here&#8217;s the snippet of the JQuery-flavored javascript I used:</p>
<pre><code class="javascript">$(document).ready(function() {
    $('body').mousemove(function(event) {
        $('#instructions').hide();

        // compute the center of the page and the distance between the center and the mouse
        // coordinates
        cx = Math.ceil($('body').width()  / 2);
        cy = Math.ceil($('body').height() / 2);
        dx = event.pageX - cx;
        dy = event.pageY - cy;

        // introducing a little parallax for the biggest light cone
        x0 = Math.ceil(cx - (dx * 0.2));
        y0 = Math.ceil(cy - (dy * 0.2));
        x1 = event.pageX;
        y1 = event.pageY;
        r0 = 300;
        r1 = 10;

        // another parallax for the text shadow
        sx = -dx * 0.03;
        sy = -dy * 0.03;

        // blur the shadow depending upon its distance
        b  =  (Math.abs(sx) + Math.abs(sy)) * 0.2;

        // simulate the light
        $('body').css('background-image', "-webkit-gradient(radial, " + x0 +" " + y0 +", "+ r0 +", "+ x1 +" "+ y1 +", "+ r1 +", from(#575757), to(#FFFFFF))");

        // simulate the shadow
        $('h1').css('text-shadow', "#444 "+ sx +"px "+ sy + "px " + b + "px");
    });
});
</code></pre>
<p>Here&#8217;s an image took from the demo, the whole page source code is available on <a href="http://github.com/sandropaganotti" target="_blank">my github account</a> as a <a href="http://gist.github.com/444897" target="_blank">gist</a>:</p>
<p><a href="http://sandropaganotti.com/wp-content/goodies/demos/we-love-shadows/we-love-shadows.html"><img title="WeLoveShadows" src="http://sandropaganotti.com/wp-content/uploads/2010/06/Untitled.jpg" alt="" width="625" height="277" /></a></p>
<p>.</p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2010/06/19/we-love-shadows-a-css3-and-javascript-based-light-source/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Un nuovo tile engine per google map</title>
		<link>http://sandropaganotti.com/2009/04/26/un-nuovo-tile-engine-per-google-map/</link>
		<comments>http://sandropaganotti.com/2009/04/26/un-nuovo-tile-engine-per-google-map/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 22:27:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Algoritmi]]></category>
		<category><![CDATA[Interfaccie]]></category>
		<category><![CDATA[Google Map]]></category>
		<category><![CDATA[Tiles]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=152</guid>
		<description><![CDATA[Conoscevo Google Map e le sue fantastiche API ma solo di recente ho deciso di spulciare un pò più a fondo la sua documentazione e ho scoperto la notevole possibilità di modificare i tiles visualizzati da Google Map trasformando questo strumento da strettamente cartografico a ZUI (zoomable user interface). Come funziona? Bisogna istanziare un nuovo [...]]]></description>
			<content:encoded><![CDATA[<p>Conoscevo <a href="http://www.google.com/maps">Google Map</a> e le sue fantastiche <a href="http://code.google.com/apis/maps/">API</a> ma solo di recente ho deciso di spulciare un pò più a fondo la sua <a href="http://code.google.com/apis/maps/documentation/">documentazione</a> e ho scoperto la notevole possibilità di modificare i tiles visualizzati da Google Map trasformando questo strumento da strettamente cartografico a ZUI (zoomable user interface).</p>
<p>Come funziona? Bisogna istanziare un nuovo oggetto della classe <a href="http://code.google.com/apis/maps/documentation/reference.html#GTileLayer">GTileLayer</a> e specificarne all&#8217;interno una funzione che, ricevuti due parametri (un oggetto <a href="http://code.google.com/apis/maps/documentation/reference.html#GPoint">GPoint </a>e un numero indicativo del livello di zoom) sappia ritornarne l&#8217;immagine appropriata.</p>
<p>Nel prossimo articolo andrò un pò più nel dettaglio, per il momento <a href="http://www.sandropaganotti.com/wp-content/map/mappa.html">vi lascio a questa proof-of-concept</a> che potrebbe trasformarsi, a breve, nella gallery ufficiale del sito.</p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2009/04/26/un-nuovo-tile-engine-per-google-map/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Effetto zoom con Scriptaculo.us e Layout Liquido</title>
		<link>http://sandropaganotti.com/2008/11/07/effetto-zoom-con-scriptaculous-e-layout-liquido/</link>
		<comments>http://sandropaganotti.com/2008/11/07/effetto-zoom-con-scriptaculous-e-layout-liquido/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 23:17:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Interfaccie]]></category>
		<category><![CDATA[Layout Fluido]]></category>
		<category><![CDATA[Scriptaculous]]></category>
		<category><![CDATA[Zoom]]></category>
		<category><![CDATA[Zui]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=3</guid>
		<description><![CDATA[Combinando dimensioni in percentuali e l&#8217;effetto morph di Scriptacolous è possibile ottenere un simpatico effetto come questo: « Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas [...]]]></description>
			<content:encoded><![CDATA[<p>Combinando dimensioni in percentuali e l&#8217;effetto morph di Scriptacolous è possibile ottenere un simpatico effetto come questo:</p>
<p><span id="more-3"></span></p>
<div id="demo1" style="width: 100%;">
<div style="padding: 2%; background: #444444 none repeat scroll 0% 0%; color: #888888; width: 100%; font-size: 100%; line-height: 160%;">« Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum, quia dolor sit, amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quaerat voluptatem. »</div>
</div>
<p>Effetto: <a onclick="$('demo1').setStyle({width: '' + $('demo1').getDimensions().width + 'px'});$('demo1').morph($('demo1').magnify_string(0.5)); return false;" href="#">zoom out</a> e <a onclick="$('demo1').morph($('demo1').magnify_string(2)); return false;" href="#">zoom in</a></p>
<h3>Parte Prima, il layout:</h3>
<p>La parte più difficile è sicuramente creare un layout al 100% liquido, per farlo ricordatevi che la percentuale espressa nel dimensionare un elemento si rapporta alla dimensione dell&#8217;elemento padre, quindi se all&#8217;interno di un contenitore di 760px ho due &lt;div&gt; una all&#8217;interno dell&#8217;altra ed entrambe di dimensione 50% la prima misurerà 760/2 = 380px e la seconda 380/2 = 190px.</p>
<p>Per quanto riguarda il testo vale quanto segue: la dimensione del font, se espressa in percentuale si rapporta alla dimensione del font del primo elemento padre espressa non in percentuale. Per fare un esempio: se nel mio box contenitore imposto font-size: 10px e all&#8217;interno di tale box utilizzo solo valori percentuali per il testo otterrò come risultato che tutto il contenuto testuale verrà rapportato a 10px secondo la percentuale specificata; quindi un font-size: 120% = 10*120/100 = 12px.</p>
<h3>Parte Seconda, lo script:</h3>
<p>Una volta completata la stesura del layout dovremmo trovarci con un box contenitore dimensionato con valori assoluti (sia per width che per font-size) contenente l&#8217;intero layout fluido. A questo punto modificando i valori del box contenitore otterremo una modifica proporzionale dell&#8217;intero layout.</p>
<p>Ma possiamo fare di più; la funzione Morph di Scriptaculo.us ci consente di creare una transizione animata tra due valori. Quindi ad esempio:</p>
<div id="box" style="border: 1px solid #333333; width: 200px; color: #333333; font-size: 20px; text-align: center;">Hello!</div>
<pre>$('box').morph("width: 300px; font-size: 6px;"); - <a href="#" onclick="$('box').morph('width: 300px; font-size: 6px;');return false;">Esegui</a></pre>
<p>Perfetto, quasi ci siamo, ora manca solo un modo per modificare queste due grandezze secondo un fattore di scala che le mantenga proporzionali, per fare questo è sufficiente creare un piccolo javascript:</p>
<pre><code class="javascript">
Element.addMethods({
  magnify_string: function(element, sf) {
    dimensions = element.getDimensions();
    font_size  = ( element.getStyle('font-size') == null ? 16 : parseFloat(element.getStyle('font-size')));
    new_width  = ( dimensions.width  > 0 ? dimensions.width  : 1.0)*sf;
    new_size   = ( font_size > 0         ? font_size         : 1.0)*sf;
    return "width: " + new_width + "px; font-size: " + new_size + "px;";
  }
})
</code></pre>
<p>Questa funzione ritorna una stringa con altezza e font-size dell&#8217;elemento su cui è invocata modificati secondo un valore di scala da 0.0 a 1.0 (0 = 0% e 1 = 100%); tale stringa si presta benissimo quindi ad essere passata all&#8217;effetto Morph ottenendo come risultato quanto mostrato all&#8217;inizio di questo articolo; per completezza allego qui il codice dei pulsanti &#8216;zoom-in&#8217; e &#8216;zoom-out&#8217; presentati in precedenza: </p>
<pre><code class="javascript">
/* Effetto zoom-out */
$('demo1').morph($('demo1').magnify_string(0.5));

/* Effetto zoom-in */
$('demo1').morph($('demo1').magnify_string(2));
</code></pre>
<p>Sandro Paganotti</p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2008/11/07/effetto-zoom-con-scriptaculous-e-layout-liquido/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

