<?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</title>
	<atom:link href="http://sandropaganotti.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://sandropaganotti.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Fri, 23 Mar 2012 19:07:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Translating wp-members with WPML</title>
		<link>http://sandropaganotti.com/2012/03/23/translating-wp-members-with-wpml/</link>
		<comments>http://sandropaganotti.com/2012/03/23/translating-wp-members-with-wpml/#comments</comments>
		<pubDate>Fri, 23 Mar 2012 18:56:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Librerie]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[wp-members]]></category>
		<category><![CDATA[WPML]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=591</guid>
		<description><![CDATA[I was asked to create a website where some content can be viewed only by registered users. I decided to go for WordPress and I choose wp-members plugin to enable member-only content as well as custom login and register pages. Everything was going pretty well when I discovered that wp-members store in the wp_options table [...]]]></description>
			<content:encoded><![CDATA[<p>I was asked to create a website where some content can be viewed only by registered users. I decided to go for WordPress and I choose <a href="http://butlerblog.com/wp-members/" target="_blank">wp-members</a> plugin to enable member-only content as well as custom login and register pages. </p>
<p><span id="more-591"></span>Everything was going pretty well when I discovered that wp-members store in the wp_options table some labels and sentences, such as fields labels and all the templates of the emails to be sent to the user. This behavior is not compatible with <a href="http://wpml.org/" target="_blank">WPML</a> and results in the same label or sentence rendered without caring of the current user language.<br />
Luckily there&#8217;s an easy workaround, we can create an hook that intercepts the request of such labels and substitue them when necessary.</p>
<p>To begin we have to create a filter call to be activated upon request of these properties, that&#8217;s easy because wp-member prefixes all of its properties with &#8216;wpmembers_&#8217;:</p>
<pre><code class="php">
if(is_plugin_active('wp-members/wp-members.php')){
	$db_options = get_alloptions();

	foreach($db_options as $name => $value){
		if(strpos($name, 'wpmembers_') === 0){
			add_filter('option_' . $name, 'i18n_wpmembers');
		}
	}
}
</code></pre>
<p>Now we can define a &#8216;i18n_wpmembers&#8217; function which determinate what property wp-members is looking for and acts by injecting translations taken from other properties, using name conventions:</p>
<pre><code class="php">
function i18n_wpmembers($value){
	global $db_options;
	$language_code = defined('ICL_LANGUAGE_CODE') ? constant('ICL_LANGUAGE_CODE') : substr(get_bloginfo("language"), 0,2);

        // load translations if available (ex: it_wpmembers_options)
	$translations = get_option($language_code . '_wpmembers_options');
	$current_option = str_replace('option_','',current_filter());

	switch($current_option){
		case 'wpmembers_fields':
			$elements_to_return = array();
			foreach($value as $i => $field){
				$new_field = $field;
				$label = $new_field[2];
				$translated_opt = $translations ? $translations[$current_option . '_' . $label] : false;
                                // inject the translation into the wp-members structured property
				$new_field[1] = ($translated_opt ? $translated_opt : $field[1]);
				$elements_to_return[] = $new_field;
			}
			return $elements_to_return;
			break;

                // continue with all the other wp-members properties

		default:
			return $value;
			break;
	}
}
</code></pre>
<p>Now all we have to do is create an extra admin page which let create the translated properties, we can achieve this following <a href="http://themeshaper.com/2010/06/03/sample-theme-options/" target="_blank">the theme options guidelines</a>.</p>
<p>Hope it might be useful! </p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2012/03/23/translating-wp-members-with-wpml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building a company logo using CSS3</title>
		<link>http://sandropaganotti.com/2012/03/15/building-a-company-logo-using-css3/</link>
		<comments>http://sandropaganotti.com/2012/03/15/building-a-company-logo-using-css3/#comments</comments>
		<pubDate>Thu, 15 Mar 2012 22:33:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Annunci]]></category>
		<category><![CDATA[Interfaccie]]></category>
		<category><![CDATA[css3]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=578</guid>
		<description><![CDATA[I&#8217;ve recently left my job to found a new company called &#8216;Comparto Web&#8216;; to showcase some of our CSS3 skills I decided to implement the logo using only HTML elements and taking advantage of some new properties such as transitions and animations. Here&#8217;s the HTML code: &#60;div id="background_gears"&#62; &#60;img src="svg/gear.svg" class="big_gear"&#62; &#60;img src="svg/gear.svg" class="small_gear"&#62; &#60;/div&#62; &#60;div [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently left my job to found a new company called &#8216;<a href="http://www.compartoweb.com" target="_blank">Comparto Web</a>&#8216;; to showcase some of our CSS3 skills I decided to implement the logo using only HTML elements and taking advantage of some new properties such as transitions and animations.</p>
<p><span id="more-578"></span><br />
Here&#8217;s the HTML code:<br />
<code class="html"></p>
<pre>&lt;div id="background_gears"&gt;
&lt;img src="svg/gear.svg" class="big_gear"&gt;
&lt;img src="svg/gear.svg" class="small_gear"&gt;
&lt;/div&gt;

&lt;div id="home"&gt;
&lt;figure&gt;
&lt;img src="svg/gear.svg" class="big_gear"&gt;
&lt;img src="svg/gear.svg" class="small_gear"&gt;
&lt;h2&gt;&lt;a data-title="Comparto Web"&gt;Comparto Web&lt;/a&gt;&lt;/h2&gt;
&lt;/figure&gt;
&lt;div&gt;
</pre>
<p></code></p>
<p>To animate the two gears I used CSS3 animations:<br />
<code class="css">
<pre>
.big_gear{
	position: absolute;
	opacity: 0.85;
	width: 7.6em;
	top: -3.0em;
	right: -2.7em;
	animation-name: clockwise;
	animation-duration: 20s;
	animation-iteration-count: infinite;
	animation-timing-function: linear;
}

.small_gear{
	opacity: 0.8;
	position: absolute;
	width: 4em;
	bottom: 0.2em;
	left: -0.8em;
	animation-name: counterclockwise;
	animation-duration: 12.808s;
	animation-iteration-count: infinite;
	animation-timing-function: linear;
}

@keyframes clockwise{
	from{
		transform: rotate(0deg);
	}
	to{
		transform: rotate(360deg);
	}
}

@keyframes counterclockwise{
	from{
		transform: rotate(360deg);
	}
	to{
		transform: rotate(0deg);
	}
}
</pre>
<p></code></p>
<p>and to create a text inset shadow effect I followed <a href="http://dabblet.com/gist/1609945" target="_blank">this</a> beautiful example from <a href="http://hugwebdesign.com/" target="_blank">Daniel Hug</a> found on Dabblet.</p>
<p>You can check the result simply by visiting <a href="http://www.compartoweb.com" target="_blank">http://www.compartoweb.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2012/03/15/building-a-company-logo-using-css3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Copy with Style bundle now available for TextMate 2</title>
		<link>http://sandropaganotti.com/2012/01/08/copy-with-style-bundle-now-available-for-textmate-2/</link>
		<comments>http://sandropaganotti.com/2012/01/08/copy-with-style-bundle-now-available-for-textmate-2/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 15:59:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Annunci]]></category>
		<category><![CDATA[bundle]]></category>
		<category><![CDATA[copy with style]]></category>
		<category><![CDATA[textmate 2]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=570</guid>
		<description><![CDATA[I&#8217;ve always owned a debt of gratitude to Bartosz Blimke and his amazingly simple &#8216;copy with style&#8217; Textmate bundle which lets you copy and paste chunks of code to external programs (eg: Keynote) while keeping all the syntax highlight working. Today I was disappointed discovering that this bundle is no longer working on Textmate 2, so I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always owned a debt of gratitude to <a href="https://github.com/bblimke">Bartosz Blimke</a> and his amazingly simple &#8216;copy with style&#8217; Textmate bundle which lets you copy and paste chunks of code to external programs (eg: Keynote) while keeping all the syntax highlight working.</p>
<p><span id="more-570"></span><br />
Today I was disappointed discovering that this bundle is no longer working on Textmate 2, so <a href="https://github.com/sandropaganotti/copy-with-style-tmbundle/tree/textmate-2">I forked the original repository</a> and made the necessary changes to bring back to work this bundle.</p>
<p>You can install with this simple instructions:</p>
<pre><code>
mkdir -p ~/Library/Application\ Support/Avian/Pristine\ Copy
cd ~/Library/Application\ Support/Avian/Pristine\ Copy/
git clone -b textmate-2 https://github.com/sandropaganotti/copy-with-style-tmbundle.git "Copy with Style.tmbundle"
</code></pre>
<p>To make this work remember to switch Textmate 2 chosen theme at least once in order to make the necessary preference be saved in .plist file (it&#8217;s still in alpha <img src='http://sandropaganotti.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2012/01/08/copy-with-style-bundle-now-available-for-textmate-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handling thousands of pics from a mobile device</title>
		<link>http://sandropaganotti.com/2011/11/27/handling-thousands-of-pics-from-a-mobile-device/</link>
		<comments>http://sandropaganotti.com/2011/11/27/handling-thousands-of-pics-from-a-mobile-device/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 21:25:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Algoritmi]]></category>
		<category><![CDATA[Approfondimenti]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[lot of images]]></category>
		<category><![CDATA[mobile safari]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=561</guid>
		<description><![CDATA[Lately I&#8217;ve been involved into a fascinating project called PepperTweet which consist in extract and visualize streams of pics from twitter starting from some search keywords. While working on a new visualization algorithm I discovered how easy it is to make mobile browsers crash trying to display a relative small amount of images.  I&#8217;ve used an [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been involved into a fascinating project called <a href="http://peppertweet.com/" target="_blank">PepperTweet</a> which consist in extract and visualize streams of pics from twitter starting from some search keywords.</p>
<p><span id="more-561"></span>While working on a new visualization algorithm I discovered how easy it is to make mobile browsers crash trying to display a relative small amount of images.  I&#8217;ve used an IPad 1 with IOs 5 for my tests, so with other devices the results may vary but I think the point is the same, there are two main problems while handling a lot of images from a mobile browser:</p>
<h3>Loading rate:</h3>
<p>If I load <a href="http://jsfiddle.net/sandro_paganotti/GMs4d/embedded/result/" target="_blank">this simple javascript code</a> in my IPad mobile safari just crash, this is because (imho) the device is not able to handle such a big image loading rate and goes into some form of buffer overflow.</p>
<p><iframe style="width: 100%; height: 300px;" src="http://jsfiddle.net/sandro_paganotti/GMs4d/embedded/js" frameborder="0" width="320" height="240"></iframe></p>
<h3>Image quantity:</h3>
<p>Using the same image (notice how in the previous example I&#8217;ve appended a random number after each image URL in order to force its download) I was able to hit another limit, the maximum number of images a mobile device can display simultaneously, <a href="http://jsfiddle.net/sandro_paganotti/brj6m/2/embedded/result/" target="_blank">this code</a> which tries to print 500 images made my mobile browser freeze:</p>
<p><iframe style="width: 100%; height: 300px;" src="http://jsfiddle.net/sandro_paganotti/brj6m/2/embedded/js" frameborder="0" width="320" height="240"></iframe></p>
<h3>A workaround:</h3>
<p>I&#8217;ve managed to load and show thousands of images using canvas, in the following example each image is loaded, printed on canvas and the discarded, also the number of concurrent loads is limited to avoid browser crash, <a href="http://jsfiddle.net/sandro_paganotti/rrdFt/4/embedded/result/" target="_blank">this example</a> uses 10000 images but I think higher image quantities can be easily reached:</p>
<p><iframe style="width: 100%; height: 300px;" src="http://jsfiddle.net/sandro_paganotti/rrdFt/4/embedded/js,result" frameborder="0" width="320" height="240"></iframe></p>
<h3>Some refinements:</h3>
<p>It seems that mobile Safari cannot handle canvas bigger than a certain value (<a href="http://jsfiddle.net/sandro_paganotti/rrdFt/5/embedded/result/" target="_blank">try this</a>), to handle this problem one solution could be using the &#8216;<a href="http://www.w3.org/TR/html5/the-canvas-element.html#dom-canvas-todataurl" target="_blank">toDataUrl</a>&#8216; method when the canvas is full of pics in order to extract a screenshot. Then this screnneshot can be added to the page before the canvas so the canvas can be cleaned and reused for the upcoming pics.</p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2011/11/27/handling-thousands-of-pics-from-a-mobile-device/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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 Augmented Reality: fuzzy results</title>
		<link>http://sandropaganotti.com/2011/05/12/html5-augmented-reality-fuzzy-results/</link>
		<comments>http://sandropaganotti.com/2011/05/12/html5-augmented-reality-fuzzy-results/#comments</comments>
		<pubDate>Thu, 12 May 2011 21:34:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Algoritmi]]></category>
		<category><![CDATA[Augmented Reality]]></category>
		<category><![CDATA[DeviceOrientationAPI]]></category>

		<guid isPermaLink="false">http://sandropaganotti.com/?p=491</guid>
		<description><![CDATA[I spent a few hours trying to figure out how to deal with the brand new deviceorientation API in order to obtain a nice Augmented Reality effect. First I searched on how to convert Euler Angles to Cartesian Coordinates and I found a nice article about that, then I downloaded the very nice Sylvester library [...]]]></description>
			<content:encoded><![CDATA[<p>I spent a few hours trying to figure out how to deal with the brand new <a href="http://dev.w3.org/geo/api/spec-source-orientation.html">deviceorientation API</a> in order to obtain a nice Augmented Reality effect. First I searched on how to convert Euler Angles to Cartesian Coordinates and I found a <a href="http://www.euclideanspace.com/maths/geometry/rotations/euler/index.htm">nice article about that</a>, then I downloaded the very nice <a href="http://sylvester.jcoglan.com/">Sylvester</a> library which lets you compute matrix operations in Javascript.</p>
<p><span id="more-491"></span></p>
<p>Then I write this code:</p>
<pre><code class="javascript">
Demo1 = function(){
  var demo1 = {};

  demo1.generatePoints = function(numero,dimensioni_box){
    var points = [];
    for(var i=0;i < numero; i++){
      var x0 = Math.floor((Math.random()-0.5)*(dimensioni_box)),
          y0 = Math.floor((Math.random()-0.5)*(dimensioni_box)),
          z0 = Math.floor((Math.random()-0.5)*(dimensioni_box)),
          x1 = x0 + 5;
          y1 = x1 + 5;
          z1 = z0;

      points.push(
        [$M([[x0],[y0],[z0]]), $M([[x1],[y1],[z1]])]
      );
    }
    return points;
  }

  demo1.init = function(evento){
    // #drawboard is a canvas element
    demo1.canvas = document.querySelector('#drawboard');
    demo1.canvas.width  = 320;
    demo1.canvas.height = 480;
    demo1.context = demo1.canvas.getContext('2d');
    demo1.points =  demo1.generatePoints(200, 100);
  };

  demo1.resetCanvas = function(){
     demo1.context.fillStyle = '#FFFFFF';
     demo1.context.fillRect(0,0, demo1.canvas.width, demo1.canvas.height);
     demo1.context.fillStyle = '#000000';
  }

  demo1.cambioOrientamento = function(evento){
    demo1.resetCanvas();

    var heading  = ((evento.alpha > 180 ? evento.alpha - 360 : evento.alpha) * Math.PI) / 180.0;
    var attitude = (evento.beta  *  Math.PI)     / 180.0;
    var bank     = (evento.gamma * (Math.PI/2.0)) / 90.0;

    var ch = Math.cos(heading),     sh = Math.sin(heading),
        ca = Math.cos(attitude),    sa = Math.sin(attitude),
        cb = Math.cos(bank),        sb = Math.sin(bank);

    var rotation_matrix = $M([
          [ch*ca  , -ch*sa*cb + sh*sb , ch*sa*sb + sh*cb    ],
          [sa      , ca*cb             , -ca*sb             ],
          [-sh*ca , sh*sa*cb + ch*sb  , -sh*sa*sb + ch*cb   ]
    ]);

    for(var i=0; i < demo1.points.length; i++){
      var pr  = rotation_matrix.x(demo1.points[i][0]);
      var x   = 160 + ((640*pr.e(1,1)) / (pr.e(3,1)));
          y   = 240 - ((640*pr.e(2,1)) / (pr.e(3,1)));
      demo1.context.fillRect(x,y,10,10);
    }
  };
  return demo1;
}();

window.addEventListener('load',Demo1.init,false);
window.addEventListener('deviceorientation',Demo1.cambioOrientamento,false);
</code></pre>
<p>If you have a device which supports the deviceorientation API (eg: iPhone4) you can test the running example here: <a href="http://sandropaganotti.com/wp-content/goodies/mobile/demo1.html">http://sandropaganotti.com/wp-content/goodies/mobile/demo1.html</a> as you might notice is still far from perfect but at the moment I've no time to refine it and so I have to leave it 'as is' ( still somehow nice IMHO ).</p>
<p>If someone got a clues on this please e-mail me at: &#115;&#097;&#110;&#100;&#114;&#111;&#046;&#112;&#097;&#103;&#097;&#110;&#111;&#116;&#116;&#105;&#064;&#103;&#109;&#097;&#105;&#108;&#046;&#099;&#111;&#109;</p>
]]></content:encoded>
			<wfw:commentRss>http://sandropaganotti.com/2011/05/12/html5-augmented-reality-fuzzy-results/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>
	</channel>
</rss>

