<?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, 25 Jul 2010 12:45:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<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>
