<?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/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Ovalpixels Blog about Web-Building</title>
	<atom:link href="http://www.ovalpixels.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ovalpixels.com/blog</link>
	<description>Tips &#38; Tricks on Web Design and Development</description>
	<lastBuildDate>Fri, 28 Jan 2011 09:17:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>HTML / CSS basic concepts and principles</title>
		<link>http://www.ovalpixels.com/blog/2011/01/25/html-css-basic-concepts-and-principles/</link>
		<comments>http://www.ovalpixels.com/blog/2011/01/25/html-css-basic-concepts-and-principles/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 21:56:10 +0000</pubDate>
		<dc:creator>vladislav</dc:creator>
				<category><![CDATA[Design]]></category>

		<guid isPermaLink="false">http://www.ovalpixels.com/blog/?p=241</guid>
		<description><![CDATA[The CSS box model The CSS box model is a W3C standard that draws the basic principles on which a box is drawn in HTML/CSS. Since every HTML element is actually a box, this principle applies to every element. Basically it states that the screen estate a box takes up is defined by the following [...]]]></description>
			<content:encoded><![CDATA[<h3>The CSS box model</h3>
<p><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2010/10/box-model.png" class="thickbox no_icon" rel="gallery-241" title="CSS standard box model"><img class="alignright size-medium wp-image-254" title="CSS standard box model" src="http://www.ovalpixels.com/blog/wp-content/uploads/2010/10/box-model-300x224.png" alt="CSS standard box model" width="300" height="224" /></a>The CSS box model is a <a  href="http://www.w3.org/">W3C standard</a> that draws the basic principles on which a box is drawn in HTML/CSS. Since every HTML element is actually a box, this principle applies to every element. Basically it states that the screen estate a box takes up is defined by the following parameters, in this order from inside to outside:</p>
<ol>
<li>width/height</li>
<li>padding</li>
<li>border</li>
<li>margin</li>
</ol>
<p>Here the content area is defined by width/height.<span id="more-241"></span></p>
<h3>Quirks mode, standards mode and almost standards mode</h3>
<p>All these terms have to do with the issue of browser compatibility. It all started back in the dawn of browsers, where every browser laid down its own flavor of standards and tried to force it just for the sake of “I have a bigger audience and think things should happen my way”.</p>
<p><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2010/10/box-model-quirksmode.png" class="thickbox no_icon" rel="gallery-241" title="CSS box model - quirks mode"><img class="alignright size-medium wp-image-255" title="CSS box model - quirks mode" src="http://www.ovalpixels.com/blog/wp-content/uploads/2010/10/box-model-quirksmode-300x224.png" alt="CSS box model - quirks mode" width="300" height="224" /></a>So, the interpretation of CSS box model was different for IE and Netscape (the big players back then). Since these differences became very inconvenient for webdevelopers it was obvious W3C standards (common standards) was the way to go. Still, many websites had already been created using the distorted rules existing so far, and if the browsers began displaying them according to standards many sites would break.</p>
<p>So developers had to be given a way to switch between the <strong>standards mode</strong> and <strong>quirks mode</strong> (the wild west of browsers). In quirks mode (the old way of displaying pages) different bugs are “available for public use”, the most notable difference in the box model being that the box size is defined by width/height, border and margin (no padding &#8211; padding actually is a part of with/height, and the content area is defined by width/height minus padding). This switch is the DOCTYPE definition that should be given in the start of every HTML document, which tells the browsers how to interpret the page &#8211; in standards or in quirks mode.</p>
<p>The “<strong>almost standards mode</strong>” is a hybrid interpretation employed by some browsers. It differs from standards mode only in the interpretation of laying out images in a table (which is in quirks mode), so that old websites using many sliced-up images laied out in a table structure are less likely to break.</p>
<h3>Semantics</h3>
<p>Probably you&#8217;ve heard this a bunch of times &#8211; &#8220;&#8230;using semantic code&#8221;. What does it actually say? Well, this is to say your code should be meaningful by itself. The code is not just there to accomplish the goal of presenting a certain piece of content on the screen in a specific way, but should be universally describing the content. Thus it would be a matter of CSS changes to make the content look in an entirely new way. Also, each content entity will be readable, described by its role &#8211; address, content, header, box, username, etc.</p>
<p>Let&#8217;s give a small example. What&#8217;s wrong with the following piece of code?</p>
<pre>&lt;span class="red"&gt;A message goes here.&lt;/span&gt;</pre>
<p>Technically &#8211; nothing. Semantically, however, the coder binds the class name to a specific website theme/look/skin, instead of keeping the code semantically meaningful. An important rule of web programming is to keep the three layers (action, design, content) separate. It would be better to use a class name like “emphasized”, for example. If we use .red we’re facing two major issues:</p>
<ul>
<li>when changing the site theme at a certain stage of development to one with green elements, for example, the .red class would look weird if it displays as green;</li>
<li>semantically the code is richer when using meaningful class names (like “emphasized”, “date”, “section”), and thus the webpage will be more delicious a bite for search engines.</li>
</ul>
<h3>Classes vs. IDs</h3>
<p>You can assign both attributes to an element, but which one should you use?</p>
<ul>
<li>From a CSS perspective <strong>IDs have higher priority</strong>. So, if you have both a class and an ID assigned to an element, the ID definition will take precedence:</li>
</ul>
<pre>&lt;style&gt;
#header { color:green; }
.myStyle { color:red; }
&lt;/style&gt;
...
&lt;div id="header" class="myStyle"&gt;Lorem Ipsum&lt;/div&gt;</pre>
<p>The text will show as green, despite the fact that .myStyle was defined on a later stage in the CSS.</p>
<ul>
<li>From HTML/JS perspective, you should only use <strong>unique IDs</strong> in a document, so it is appropriate to use IDs for major document elements like #header, #footer, #content, and classes for elements that are found repeating in a document (.box, .column, .emphasized).</li>
</ul>
<h3>The advantages of writing standard-based DIV based HTML</h3>
<p>CSS-based layouts have been around for over 10 years now, so it is a sin not to use them. It has multiple advantages before the table-based layouts, and some of them are:</p>
<ul>
<li>you get everything done with a <strong>smaller amount of code</strong>, thus achieving a better <a  href="http://www.seochat.com/seo-tools/code-to-text-ratio/">code-to-text ratio</a>, which affects SEO ranking, too;</li>
<li>you get <strong>better control over separate elements</strong> (e.g. moving the logo around is much easier and does not require re-slicing the whole site layout); this is much like the ease of editing a layered Photoshop/GIMP file vs. editing a flattened JPG;</li>
<li>you get<strong> better separation of content, design and behaviour</strong>; thus different team members can work separately and independently on different aspects of a site (design, development), without interfering; also, you get a much easier time at debugging issues and making changes;</li>
<li>you get an<strong> easy way to make any design changes</strong> (effectively switch between themes) by not changing a <strong>single line of content code</strong>; all you have to edit is your CSS file;</li>
<li>you get a thing to brag about in front of your friends &#8211; writing compact and standards-compatible code is certainly an accomplishment <img src='http://www.ovalpixels.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li>by writing standard code you make sure<strong> your site will work and look properly in a vast amount of browsers</strong> &#8211; even in future browsers, ones that will come out 2 years from now.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.ovalpixels.com/blog/2011/01/25/html-css-basic-concepts-and-principles/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adding automatic CSS timestamp to a Thematic child theme</title>
		<link>http://www.ovalpixels.com/blog/2010/08/29/adding-automatic-css-timestamp-to-a-thematic-child-theme/</link>
		<comments>http://www.ovalpixels.com/blog/2010/08/29/adding-automatic-css-timestamp-to-a-thematic-child-theme/#comments</comments>
		<pubDate>Sat, 28 Aug 2010 23:33:55 +0000</pubDate>
		<dc:creator>vladislav</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Thematic]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.ovalpixels.com/blog/?p=194</guid>
		<description><![CDATA[I recently had a small design job to do on a site based on the Thematic WordPress theme framework. It was all creating graphics and adding them to the CSS file of the blog. While completing this task I stumbled upon several issues, so I woud like to share the solutions I used for them. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-250" src="http://www.ovalpixels.com/blog/wp-content/uploads/2010/08/css-screenshot-timestamp1.png" alt="" width="213" height="139" />I recently had a small design job to do on a site based on the <a  href="http://themeshaper.com/thematic/" target="_blank"> Thematic </a> WordPress theme framework. It was all creating graphics and adding them to the CSS file of the blog. While completing this task I stumbled upon several issues, so I woud like to share the solutions I used for them.</p>
<h3><span id="more-194"></span>Issue 1: Browser cache</h3>
<p>As you know, visitors to a site would get served the latest version of a file only if it already doesn&#8217;t exist in the local browser cache (or the local copy is old enough to expire). So only a first-time visitor would surely get the latest CSS version, but what about returning visitors? I needed to make sure they get the new CSS file without having to manually hard-refresh their browser. This is where the CSS timestamp technique comes into place.</p>
<h3>Issue 2: Continuous updates</h3>
<p>In any future updates of the CSS file, I would need to change the timestamp each time, which brings in a bit of inconvenience. This is where generating an <strong><em>automatic timestamp on file change</em></strong> comes in quite handy, if not priceless.</p>
<h3>Issue 3: Updating the Thematic stylesheet call function</h3>
<p>The site used Thematic as a base parent theme, and the <a  href="http://codex.wordpress.org/Child_Themes">child theme</a> of the site contained just a few files &#8211; an index.php file, a css file, a functions.php file, and an /images folder. This is the beauty of child themes introduced recently in WordPress &#8211; you can base your theme on an existing one and add only the files you need to change in your child theme folder. As opposed to directly changing the main theme, this technique protects your changes from any future updates of the main theme, which would overwrite your changes. By using a child theme you effectively preserve your changes in a separate theme folder.</p>
<p>However this also prevents you from directly editing PHP code that includes the stylesheet without adding too much excess code. This is where we will use <a  href="http://themeshaper.com/filters-wordpress-child-themes/">WordPress filters</a> to do the task.</p>
<p>Now let&#8217;s see the solutions to these issues.</p>
<h3>Solution to issue 1 (Browser cache)</h3>
<p>Here is how a normal call to a CSS file looks like in HTML:</p>
<pre>&lt;link href="style.css" type="text/css" rel="stylesheet" /&gt;</pre>
<p>As mentioned before, an elegant solution to the browser cache issue is appending a unique string to the filename call as a parameter passed on to the CSS file:</p>
<pre>&lt;link href="style.css?some_unique_string" type="text/css" rel="stylesheet" /&gt;</pre>
<p>Usually a version number is used, e.g.:</p>
<pre>&lt;link href="style.css?ver=12" type="text/css" rel="stylesheet" /&gt;</pre>
<p>or a date:</p>
<pre>&lt;link href="style.css?20100829" type="text/css" rel="stylesheet" /&gt;</pre>
<p>The idea is generally the same. CSS does not make use of that parameter, but the browser gets tricked that you&#8217;re making a call to a different file (due to the different value of the href attribute), so it downloads it from the server. Voila!</p>
<h3>Solution to issue 2 (Continuous updates)</h3>
<p>Applying the CSS timestamp trick is great, but leaves room for error. Sometimes I might forget to change the version / timestamp, or I may just get tired of constantly changing it. This is why the solution I found <a  href="http://www.prelovac.com/vladimir/adding-version-to-theme-css-file">published here</a> really made my day. What it does is automatically append a unique number based on the actual date / time the CSS file was <em>changed on the server </em>by using a PHP function ( filemtime() ) to check for it<em>.</em></p>
<p>Here is how a line of HTML/PHP code using this method would look:</p>
<pre>&lt;link href="style.css?&lt;?php echo filemtime('/server/path/to/css/file/style.css'); ?&gt;"</pre>
<pre> rel="stylesheet" type="text/css" /&gt;</pre>
<p>This will result in a unique number appended to the CSS call <em>each time the file is changed</em>. No more need to worry you forgot anything.</p>
<h3>Solution to issue 3 (Tinkering with the CSS call function in Thematic)</h3>
<p>I opened the header.php file of the Thematic parent theme to see how the CSS file is being included. I only saw a bunch of PHP functions being called, going like this:</p>
<pre>    // Creating the doctype
    thematic_create_doctype();
    echo " ";
    language_attributes();
    echo "&gt;\n";

    // Creating the head profile
    thematic_head_profile();

    // Creating the doc title
    thematic_doctitle();

    // Creating the content type
    thematic_create_contenttype();
...</pre>
<p>Not a line of HTML. But I noticed one of the functions was this:</p>
<pre>    // Loading the stylesheet
    thematic_create_stylesheet();</pre>
<p>It would obviously take care of inserting the stylesheet. A short run through the Thematic file structure showed this function was defined in /wp_thematic_folder /library /extensions /header-extensions.php:</p>
<pre>// Located in header.php
// creates link to style.css
function thematic_create_stylesheet() {
    $content = "\t";
    $content .= "&lt;link rel=\"stylesheet\" type=\"text/css\" href=\"";
    $content .= get_bloginfo('stylesheet_url');
    $content .= "\" /&gt;";
    $content .= "\n\n";
    echo apply_filters('thematic_create_stylesheet', $content);
}</pre>
<p>It clearly shows how the HTML code for including the CSS file is built and assigned to a $content variable. What I needed is to change the output of this function. I accomplished that by adding a filter that would replace the output of the existing thematic_create_stylesheet() function with what I need. Adding a filter is easy &#8211; just edit the functions.php file of your theme (in this case &#8211; the child theme). This is how it looks:</p>
<pre>function timestampCSS($content) {
    $content = "\t";
    $content .= "&lt;link rel=\"stylesheet\" type=\"text/css\" href=\"";
    $content .= get_bloginfo('stylesheet_url');
    $content .= '?' . filemtime( get_stylesheet_directory() . '/style.css');
    $content .= "\" /&gt;";
    $content .= "\n\n";
    return $content;
}
add_filter ('thematic_create_stylesheet', 'timestampCSS');</pre>
<p>What I did was create a new function ( timestampCSS() ) which would return the output I need, and then hook it as a filter to the old function ( thematic_create_stylesheet() ), so that each time the old function is executed my new function will be, too.<span style="font-size: 13.2px;"> The last line ( add_filter() ) effectively tells WordPress to use the output of timestampCSS() instead of the one of thematic_create_stylesheet().</span></p>
<p>So this is how you can use a combination of handy techniques to make your work on styling Thematic a bit less tedious and make it work independently of the updates of the parent theme.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ovalpixels.com/blog/2010/08/29/adding-automatic-css-timestamp-to-a-thematic-child-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating and visualizing customizable products</title>
		<link>http://www.ovalpixels.com/blog/2010/02/27/creating-and-visualizing-customizable-products/</link>
		<comments>http://www.ovalpixels.com/blog/2010/02/27/creating-and-visualizing-customizable-products/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 10:13:07 +0000</pubDate>
		<dc:creator>georgi</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[alpha]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[day e-commerce]]></category>
		<category><![CDATA[e-commerce]]></category>
		<category><![CDATA[e-shops]]></category>
		<category><![CDATA[online store app]]></category>
		<category><![CDATA[open-source solution]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[server processing part]]></category>
		<category><![CDATA[shirt builder]]></category>
		<category><![CDATA[store app Since]]></category>

		<guid isPermaLink="false">http://www.ovalpixels.com/blog/?p=142</guid>
		<description><![CDATA[Modern day e-commerce needs to be very hi-tech to get advantage over the competition. We have quite a lot of examples of e-shops implementing amazing technology to become more attractive to customers. One of these is the ability to customize a product and view a realistic visualization of how it would look like in real [...]]]></description>
			<content:encoded><![CDATA[<p>Modern day e-commerce needs to be very hi-tech to get advantage over the competition. We have quite a lot of examples of e-shops implementing amazing technology to become more attractive to customers. One of these is the ability to customize a product and view a realistic visualization of how it would look like in real life. We have already done something similar for <a  title="3D virtual configurator" href="http://stonecenter-bg.com/?lang=en#configurators.php" target="_blank">these guys</a> &#8211; it includes some 3D rendering, jQuery and CSS. But this time we have to use other tools and materials.<span id="more-142"></span></p>
<h3>The recipe</h3>
<p>Here are the ingredients we have:</p>
<ol>
<li>client: students startup</li>
<li>application: online store</li>
<li>product: customizable male and female business shirts</li>
<li>no flash</li>
<li>budget: limited</li>
<li>materials: none</li>
<li>deadline: tight</li>
<li>expectations: high</li>
</ol>
<p>So, we have to mix all these and get something delicious in the end.</p>
<h2>The online store app</h2>
<p>Since the whole site has to be clean and straightforward, we decided it would be best to design it from scratch using CakePHP instead of trying to bend any existing open-source solution. We don&#8217;t need all the stuff ZenCart provides but we need that shirt builder which we can hardly implement into any OSS shop.</p>
<h2>Raw materials</h2>
<p>None. The client didn&#8217;t have any materials to provide us with except for some low-resolution, all-messed-up pictures from their shirt-sewing factory. They didn&#8217;t have time or budget for 3D modeling (which could prove to be quite fancy and realistic) and we had to</p>
<h3>Photoshoot</h3>
<p>We hired <a  href="http://mborisov.com/" target="_blank">this fella</a> for the project and I think he did quite well.</p>
<p><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/shirt_front.jpeg" class="thickbox no_icon" rel="gallery-142" title=""><img class="alignnone size-medium wp-image-143" src="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/shirt_front-221x300.jpg" alt="" width="133" height="180" /></a><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/shirt_back.jpeg" class="thickbox no_icon" rel="gallery-142" title=""><img class="alignnone size-medium wp-image-144" src="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/shirt_back-202x300.jpg" alt="" width="121" height="180" /></a><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/shirt_side.jpeg" class="thickbox no_icon" rel="gallery-142" title=""><img class="alignnone size-medium wp-image-145" src="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/shirt_side-129x300.jpg" alt="" width="77" height="180" /></a><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/shirt_sleeve.jpeg" class="thickbox no_icon" rel="gallery-142" title=""><img class="alignnone size-medium wp-image-146" src="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/shirt_sleeve-169x300.jpg" alt="" width="101" height="180" /></a></p>
<p>The pictures don&#8217;t look fancy (to me) but I was amazed what good job they did for us.</p>
<h2>Customizable Product Visualization Technology</h2>
<p>For the shirt builder we needed a solution which would allow us to generate images on the server so that we don&#8217;t have to create all the gazillion possible visualizations. We had to be able to &#8220;apply&#8221; all fabrics to all shirt elements ( fit, sleeves, cuffs, etc ). And the client wanted a fast and smooth experience for the end-user with no Flash!</p>
<p>We came up with the idea to create a mask for all shirt elements like in photoshop, use it to &#8220;cut out&#8221; the fabric in the particular shape and then add another layer which would represent shades and folds.</p>
<p><a  href="http://wideimage.sourceforge.net/" target="_blank">WideImage</a> was chosen for the server processing part. However, it turned out we were jumping in the dark.</p>
<h3>Fabric material</h3>
<p>Well, ok, I lied &#8211; the client gave us some picture of the fabrics they wanted to use. They were good enough and after some processing we got this</p>
<p><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/fabric-tile.jpg" class="thickbox no_icon" rel="gallery-142" title=""><img class="alignnone size-medium wp-image-147" src="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/fabric-tile.jpg" alt="" width="94" height="104" /></a></p>
<p>We had to make a canvas and tile that image in there. That was an easy task for WideImage.</p>
<p>We first load the fabric image and resize it on the fly &#8211; otherwise it would look too big on the final image. We then create the canvas and fill it with repeating instances of the fabric image &#8211; finally, cut out a shirt shape.</p>
<p><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/index4php.png" class="thickbox no_icon" rel="gallery-142" title=""><img class="alignnone size-medium wp-image-148" src="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/index4php-210x300.png" alt="" width="126" height="180" /></a><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/male-mask-normal.png" class="thickbox no_icon" rel="gallery-142" title=""><img class="alignnone size-medium wp-image-150" src="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/male-mask-normal-210x300.png" alt="" width="126" height="180" /></a><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/index4php1.png" class="thickbox no_icon" rel="gallery-142" title=""><img class="alignnone size-medium wp-image-151" src="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/index4php1-210x300.png" alt="" width="126" height="180" /></a></p>
<p>But we have a small problem here &#8211; we need to add the layer for folds and shades now and with this approach it has to reside in a separate file. That&#8217;s not elegant enough&#8230;</p>
<p>We came up with the idea to</p>
<h4>combine the image mask and folds layer into one file</h4>
<p>How to do that? We use the RGB channels of the image to hold the mask and the alpha channel to hold the folds and shades layer. This way we can have just one file to hold all the information we need to generate our image.</p>
<h3>Performance</h3>
<p>Nothing is as easy as it sounds. WideImage has some wonderful methods like getChannels() to get the RGB and alpha channels into different image resources and applyMask() to cut out the shirt element shape from the fabric-tiled canvas but these come with enormous performance hits. Unfortunately, PHP and GD2 do not offer native functions for these tasks and WideImage uses &#8220;for&#8221; loops to go through all pixels of the image to do the necessary processing. So, the algorithm goes like that</p>
<ol>
<li>go through the image pixel by pixel go get its RGB channels and alpha channels and store them in different image resources (mask and folds layer)</li>
<li>once again go through the mask image (which has same size) pixel by pixel to cut out the fabric canvas</li>
<li>apply the folds layer on top of the cut out image</li>
</ol>
<p>This averaged at 8 seconds on our server for a 350&#215;500 image!</p>
<h4>Cache</h4>
<p>We decided we could use some caching which would save us troubles &#8211; we calculate we would need around 1GB of space for that cache which is not a big deal but 8 seconds is still a monster.</p>
<h4>Solution</h4>
<p>We came up with a solution which was similar to what WideImage does but we now do all the processing in a single for loop which saves quite a lot of time. We managed to keep the figure down to 2-3secs for an uncached image which is bearable. In he end the image looks like that</p>
<p><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/demo1.png" class="thickbox no_icon" rel="gallery-142" title=""><img class="alignnone size-medium wp-image-152" src="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/demo1-210x300.png" alt="" width="168" height="240" /></a><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/demo3.png" class="thickbox no_icon" rel="gallery-142" title=""><img class="alignnone size-medium wp-image-154" src="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/demo3-210x300.png" alt="" width="168" height="240" /></a><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/demo2.png" class="thickbox no_icon" rel="gallery-142" title=""><img class="alignnone size-medium wp-image-153" src="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/demo2-210x300.png" alt="" width="168" height="240" /></a></p>
<p>This is still a work in progress and we need a few more things to enhance, so if you have any suggestions, go ahead and shoot!</p>
<p><em><strong>Update:</strong></em> We launched the website some time ago. Here are some final images:</p>
<p><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/male-front.jpeg" class="thickbox no_icon" rel="gallery-142" title=""><img class="alignleft size-full wp-image-191" src="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/male-front.jpeg" alt="" width="170" height="243" /></a><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/male-side.jpeg" class="thickbox no_icon" rel="gallery-142" title=""><img class="alignleft size-full wp-image-189" src="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/male-side.jpeg" alt="" width="170" height="243" /></a><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/male-back.jpeg" class="thickbox no_icon" rel="gallery-142" title=""><img class="alignleft size-full wp-image-192" src="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/male-back.jpeg" alt="" width="170" height="243" /></a></p>
<p><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/female-front.jpeg" class="thickbox no_icon" rel="gallery-142" title=""><img class="alignleft size-full wp-image-188" src="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/female-front.jpeg" alt="" width="170" height="243" /></a><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/female-side.jpeg" class="thickbox no_icon" rel="gallery-142" title=""><img class="alignleft size-full wp-image-187" src="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/female-side.jpeg" alt="" width="170" height="243" /></a><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/female-back.jpeg" class="thickbox no_icon" rel="gallery-142" title=""><img class="alignleft size-full wp-image-190" src="http://www.ovalpixels.com/blog/wp-content/uploads/2010/02/female-back.jpeg" alt="" width="170" height="243" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ovalpixels.com/blog/2010/02/27/creating-and-visualizing-customizable-products/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Non-destructive techniques in Photoshop image manipulation &#8211; part 1</title>
		<link>http://www.ovalpixels.com/blog/2009/03/06/non-destructive-techniques-in-image-manipulation/</link>
		<comments>http://www.ovalpixels.com/blog/2009/03/06/non-destructive-techniques-in-image-manipulation/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 22:14:11 +0000</pubDate>
		<dc:creator>vladislav</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[photoshop]]></category>
		<category><![CDATA[techniques]]></category>

		<guid isPermaLink="false">http://www.ovalpixels.com/blog/?p=25</guid>
		<description><![CDATA[&#8230;or adding a pinch of parametricity to your photoshop work Intro Imagine the following: you have worked on a Photoshop project, spending hours on end over it. You may not have slept this night, but you know that every drop of sweat was worth it &#8211; after all you have created wonders! The result is [...]]]></description>
			<content:encoded><![CDATA[<h4>&#8230;or adding a pinch of parametricity to your photoshop work</h4>
<h3>Intro</h3>
<p>Imagine the following: you have worked on a Photoshop project, spending hours on end over it. You may not have slept this night, but you know that every drop of sweat was worth it &#8211; after all you have created wonders! The result is quite impressive, and of course when you show it to the customer he is totally into it, and says:</p>
<blockquote><p>&#8220;This is great! I love it! But <strong>what if </strong>we make the image of the little girl a bit bigger?&#8230; Just a bit &#8211; it shouldn&#8217;t be an issue, right?&#8221;</p></blockquote>
<p>OR</p>
<blockquote><p>&#8220;That tree you have cut out from the background&#8230; <strong>Let&#8217;s</strong> get it back and see if it is better&#8221;</p></blockquote>
<p>Well&#8230; Let me hear you say &#8220;Arrghhh!!!&#8221; <span id="more-25"></span></p>
<h3>How transformations change the image irreversibly</h3>
<p>In order to illustrate that, let&#8217;s look at a simple case. We will get a simple image, rotate it 45 degrees, then rotate it back 45 degrees and compare the difference between the original, untransformed image, and the supposed-to-be-the-same, rotated back and forth, image. Here goes the three step process:</p>
<div id="attachment_134" class="wp-caption aligncenter" style="width: 360px"><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2009/03/fig1.png" class="thickbox no_icon" rel="gallery-25" title="Rotating an image 45 degrees and back again"><img class="size-full wp-image-134" src="http://www.ovalpixels.com/blog/wp-content/uploads/2009/03/fig1.png" alt="Rotating an image 45 degrees and back again" width="350" height="696" /></a><p class="wp-caption-text">Rotating an image 45 degrees and back again.</p></div>
<p>As you can see, the image we ended up with is quite far from the one we started with. And this is the result of only two consecutive transformations that require interpolation (scaling/rotation). Quite a bunch of info is lost, since <strong>each transformation is irreversible, and the result serves as a base for any following transformation</strong>.</p>
<p>Going back to the scenario described in the intro: since you have manipulated the original images (rotated them, scaled them down, applied filters and color corrections to them), you cannot just go back, change a little something, and expect all the rest of the manipulations down the line to &#8216;re-apply&#8217; and remain the same.</p>
<p>On the other hand, if you go back in history to the stage you want to change, you will lose all the undone actions. So what you will have to do it basically re-do everything from that moment on.</p>
<p>This is just one example when you would wish your image manipulations are adjustable even <strong>after </strong>they&#8217;ve been done.</p>
<h3>Have no fear &#8211; the solution is here</h3>
<p>Fortunately there is a way to achieve this &#8211; you have a series of tools in your hands that can help you make your actions reversible and adjustable, and the team working on Photoshop, as a leading product on the market, seems to think in the same direction, adding to these features in the latest releases.  Here is a quick list:</p>
<ul>
<li>masks / clipping masks</li>
<li>adjustment layers</li>
<li>smart objects / smart filters</li>
<li>history brush</li>
</ul>
<h3>Masks: don&#8217;t delete &#8211; just hide</h3>
<p>This is a quite basic technique. The idea is to just <strong>hide </strong>portions of the image you don&#8217;t need instead of erasing them. A mask layer is actually a grayscale &#8220;map overlay&#8221;, where white represents complete opaqueness, black &#8211; full transparency, and the shades of grey &#8211; levels of semi-transparency. Boy, does that help out in that &#8220;get-the-tree-back&#8221; situation &#8211; you just need to paint the mask white where the pixels of the hidden tree are and voila &#8211; there it is.</p>
<p>Adding a mask to a layer in Photoshop is just a click away &#8211; select the layer to add the mask to, and then click on the &#8220;Add layer mask&#8221; button in the &#8220;Layers&#8221; palette:</p>
<div id="attachment_136" class="wp-caption aligncenter" style="width: 264px"><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2009/03/add-mask.png" class="thickbox no_icon" rel="gallery-25" title="Adding a mask - select the layer to add the mask to, and then click on the &quot;Add layer mask&quot; button in the &quot;Layers&quot; palette."><img class="size-full wp-image-136" src="http://www.ovalpixels.com/blog/wp-content/uploads/2009/03/add-mask.png" alt="Adding a mask - select the layer to add the mask to, and then click on the &quot;Add layer mask&quot; button in the &quot;Layers&quot; palette." width="254" height="93" /></a><p class="wp-caption-text">Adding a mask</p></div>
<h3>Clipping Masks &#8211; another breed</h3>
<p>Sometimes you need to restrain the visibility of a layer to the extent of a certain object that is on another layer.  Let&#8217;s say you want to achieve this effect:</p>
<p><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2008/11/clipping-masks-01.png" class="thickbox no_icon" rel="gallery-25" title=""><img class="aligncenter size-full wp-image-43" src="http://www.ovalpixels.com/blog/wp-content/uploads/2008/11/clipping-masks-01.png" alt="" width="425" height="59" /></a></p>
<p>This is an image seen through a &#8216;hole&#8217; defined by a text layer. Achieving this through a regular mask on the image layer will do quite the same for you, but there will be two disadvantages:</p>
<ul>
<li>If you want to change the text, you will need to re-create the mask, too.</li>
<li>You will have some redundancy by having an extra element &#8211; both a text layer and a mask.</li>
</ul>
<p><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2008/11/clipping-masks-02.png" class="thickbox no_icon" rel="gallery-25" title=""><img class="alignright size-full wp-image-44" src="http://www.ovalpixels.com/blog/wp-content/uploads/2008/11/clipping-masks-02.png" alt="" width="199" height="97" /></a>Now let&#8217;s see how to get the same result through a clipping mask:</p>
<ol>
<li>Create the text layer.</li>
<li>Drag the image layer over the text layer.</li>
<li>Alt-click (Option-click for Mac) on the border between the two layers to get the text layer act as a clipping mask for the image layer.</li>
</ol>
<p>HINT: You can add as much clipped layers as needed.</p>
<p><strong>Pros: </strong>You get a dynamically updated mask. You simplify things by having a single layer acting both as a layer and a mask for other layers.</p>
<p><strong>Cons: </strong>Setting the opacity of the clipping mask influences the opacity of the clipped layers (<strong>note: </strong>there is no vice versa)</p>
<h3>Adjustment layers: don&#8217;t harm your pixels</h3>
<p><img class="size-full wp-image-32 alignright" src="http://www.ovalpixels.com/blog/wp-content/uploads/2008/11/adjustment-layers-01.png" alt="" width="188" height="247" />The most common <strong>image correction</strong> techniques involve tinkering with <strong>brightness/contrast</strong>, <strong>levels</strong>, <strong>hue/saturation</strong>, <strong>curves</strong>, <strong>exposure</strong> or <strong>converting to grayscale</strong>. All these operations change the original image, and in most cases you could <strong>lose information</strong> (like losing color with grayscale conversion, or losing detail in burnt-out areas when brightening an image). So it is a great thing all these (and more) are available as an adjustable alternative &#8211; the so-called &#8216;adjustment layers&#8217;.</p>
<p><strong>Applying an adjustment</strong> is as easy as inserting a new layer (see the screenshot) in the layer stack. Click on the &#8220;Create new fill or adjustment layer&#8221; button in the &#8220;Layers&#8221; palette, and choose an adjustment to apply. The adjustment is then applied to all layers down the stack. If you later want to change the parameters of the adjustment (e.g. the brightness value), just double click on its thumbnail to get the adjustment settings dialogue. You can also move the layer up and down the stack, thus controlling which layers are affected by it. If you don&#8217;t want the adjustment anymore &#8211; you can temporarily hide it or delete it and everything will be as if it never existed.</p>
<blockquote><p>So, an adjustment layer is like an <strong>instruction set</strong> for a change (e.g. &#8216;change the brightness level to +35),  and not the change itself. This <strong>allows us to change the parameters of the adjustment</strong> (in this case &#8211; brightness and contrast levels) anytime. This is why I call it &#8216;parametric&#8217;.</p></blockquote>
<p><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2008/11/img_0633-gray-focus.jpg" class="thickbox no_icon" rel="gallery-25" title=""><img class="alignright size-medium wp-image-37" src="http://www.ovalpixels.com/blog/wp-content/uploads/2008/11/img_0633-gray-focus-300x225.jpg" alt="" width="144" height="108" /></a><strong>Co</strong><strong>nstraining the effect of the adjustment</strong> to a certain portion of the image (like, in the image on the right, graying out the whole image except the flower), is a matter of drawing in the mask of the adjustment layer (see &#8220;<em>Masks</em>&#8220;).</p>
<p><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2008/11/adjustment-layers-02.png" class="thickbox no_icon" rel="gallery-25" title=""><img class="alignleft size-medium wp-image-38" src="http://www.ovalpixels.com/blog/wp-content/uploads/2008/11/adjustment-layers-02-196x300.png" alt="" width="94" height="144" /></a>The tricky part is if you want to <strong>apply an adjustment to a single layer / a group of layers</strong> in the middle of the stack.</p>
<p><strong>Restrain the effect to a group of layers:</strong> Since the adjustment layer affects all layers below, a way to restrain its effect is group the layers with the adjustment layer on top of the the group stack (see left).</p>
<p><a  href="http://www.ovalpixels.com/blog/wp-content/uploads/2008/11/adjustment-layers-03.png" class="thickbox no_icon" rel="gallery-25" title=""><img class="alignright size-full wp-image-39" src="http://www.ovalpixels.com/blog/wp-content/uploads/2008/11/adjustment-layers-03.png" alt="" width="213" height="323" /></a>For <strong>restraining the effect to a single layer</strong> you can avoid creating an unnecessary group, but use the layer (Layer 2) as a <a  href="#masksclip">clipping mask</a> for the adjustment layer instead (see right). You can achieve that by Alt-clicking (Option-click for Mac) on the border between the two layers in the layer stack.</p>
<p><strong>Pros: </strong>Transformations are not lossy, because they are undoable and adjustable.</p>
<p><strong>Cons:</strong> None that I know of.</p>
<p>That&#8217;s it for now. The next couple of tools (<em>smart objects/filters</em> and history brush) will be coming up shortly in the &#8220;<em>Non-destructive techniques in Photoshop image manipulation &#8211; part 2</em>&#8221; article.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ovalpixels.com/blog/2009/03/06/non-destructive-techniques-in-image-manipulation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making fancy websites without Flash 2: Animating background image</title>
		<link>http://www.ovalpixels.com/blog/2009/02/21/making-fancy-websites-without-flash-animating-background-image/</link>
		<comments>http://www.ovalpixels.com/blog/2009/02/21/making-fancy-websites-without-flash-animating-background-image/#comments</comments>
		<pubDate>Sat, 21 Feb 2009 18:48:43 +0000</pubDate>
		<dc:creator>georgi</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.ovalpixels.com/blog/?p=87</guid>
		<description><![CDATA[This is a continuation of the Making fancy website without Flash entry from a few days ago. To make the story short &#8211; I will try and show you some jQuery alernatives for popular Flash animation. We will start with a Smooth background image swap &#8211; jQuery Background-Image Transition Plugin I will show you an [...]]]></description>
			<content:encoded><![CDATA[<p>This is a continuation of the <a  href="http://www.ovalpixels.com/blog/2009/02/20/making-fancy-websites-without-flash-introduction/" target="_blank">Making fancy website without Flash</a> entry from a few days ago. To make the story short &#8211; I will try and show you some jQuery alernatives for popular Flash animation. <span id="more-87"></span>We will start with a</p>
<h3>Smooth background image swap &#8211; jQuery Background-Image Transition Plugin</h3>
<p>I will show you an example right now, so you know what I am talking about.</p>
<p><a  title="background-image-transition-example" href="http://www.ovalpixels.com/bgImageTransition/">Here is a working example</a></p>
<p>What we basically do is:</p>
<ol>
<li>Create an additional hidden &lt;div&gt; element on top ( using z-index ) of the element we want to animate</li>
<li>Load the new image in the in the cache in the background, so that the effect is smooth</li>
<li>Set the new src to the new &lt;div&gt; element</li>
<li>fadeIn() the new &lt;div&gt; element so that it creates the illusion that the background image of our initial div is smoothly changing</li>
<li>Optional step &#8211; if we need to change the image once again, go from 2 to 5 but setting the new src to our <em>initial </em>&lt;div&gt; and then using <em>fadeOut()</em> on the new element, so that it disappears and the new image is set as background to the old &lt;div&gt;. This way we won&#8217;t have an infinitive increase of the z-index and won&#8217;t actually change the z-index of the initial &lt;div&gt;</li>
</ol>
<p>OK, let&#8217;s get to work, we will start with the HTML markup:</p>
<p>&lt;div id=&#8221;backImage&#8221;&gt;&lt;/div&gt;</p>
<p>Well, that was pretty easy: we have a simple &lt;div&gt; element with some demo text and just next to it we add that additional &lt;div&gt; which we will need for the animation.</p>
<p>So, here is the CSS:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#backImage</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">z-index</span><span style="color: #00AA00;">:</span> -<span style="color: #cc66cc;">2</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">600px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">800px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'path/to/initial/img'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>We just set a height and width of the element so that we are sure the image will actually be shown. It is generally a good idea to have the z-index set to a negative number while other elements have a greater z-index value.</p>
<p>We will use <a  href="http://plugins.jquery.com/project/bgImageTransition/" target="_blank">jQuery&#8217;s Background-Image Transition Plugin</a> for our example.</p>
<p>First, add jQuery and the plugin</p>
<p>&lt;script lang=&#8221;Javascript&#8221; src=&#8221;path/to/jQuery.js&#8221; type=&#8221;text/javascript&#8221;&gt; &lt;/script&gt;<br />
&lt;script lang=&#8221;Javascript&#8221; src=&#8221;path/to/jQuery.bgImageTransition.js&#8221; type=&#8221;text/javascript&#8221;&gt; &lt;/script&gt;</p>
<p>Then, at the end of the document, add the following lines:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery<span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#backImage'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bgImageTransition</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'path/to/new/image'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
        duration<span style="color: #339933;">:</span> <span style="color: #3366CC;">'slow'</span><span style="color: #339933;">,</span>
        easing<span style="color: #339933;">:</span> <span style="color: #3366CC;">'linear'</span><span style="color: #339933;">,</span>
        helperElementId<span style="color: #339933;">:</span> <span style="color: #3366CC;">'backImage2'</span><span style="color: #339933;">,</span>
        zindex<span style="color: #339933;">:</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span>
        callback<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
           <span style="color: #006600; font-style: italic;">//do sth</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The only mandatory argument is the path to the new image. The optional second argument is an object holding some tweaks. You can set the desired duration, easing, helperElementId ( which is generated by the plugin ), z-index of the helperElement ( by default it will take the selected element&#8217;s zindex and increment by 1 ) and a callback function in case you want to execute some functionality when the transition is over.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ovalpixels.com/blog/2009/02/21/making-fancy-websites-without-flash-animating-background-image/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
		<item>
		<title>Making fancy websites without Flash: Introduction</title>
		<link>http://www.ovalpixels.com/blog/2009/02/20/making-fancy-websites-without-flash-introduction/</link>
		<comments>http://www.ovalpixels.com/blog/2009/02/20/making-fancy-websites-without-flash-introduction/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 11:56:11 +0000</pubDate>
		<dc:creator>georgi</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[favorite tool]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[javascript technology]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[web front-end developers]]></category>

		<guid isPermaLink="false">http://www.ovalpixels.com/blog/?p=88</guid>
		<description><![CDATA[Flash Adobe Flash is no doubt a favorite tool for a lot of web front-end developers and designers. It is widely supported on a variety of platforms and browsers and features a rich and cohesive set of tools and instruments. Some people even say it is the next evolutionary step of the Web. Why not [...]]]></description>
			<content:encoded><![CDATA[<h3>Flash</h3>
<p style="64.125px;">Adobe Flash is no doubt a favorite tool for a lot of web front-end developers and designers. It is widely supported on a variety of platforms and browsers and features a rich and cohesive set of tools and instruments. Some people even say it is the next evolutionary step of the Web.</p>
<h3>Why not then?</h3>
<p style="64.125px;">Even though Flash is great, it has its drawbacks ( of course, I wouldn&#8217;t be writing this blog post otherwise ). <span id="more-88"></span>Here I am talking about a completely Flash made website, not just small fragments of it.</p>
<ul style="64.125px;">
<li>It is extremely <strong>SEO unfriendly</strong>. Although Google <a  href="http://googleblog.blogspot.com/2008/06/google-learns-to-crawl-flash.html" target="_blank">stated</a> back in the middle of 2008 that they have <em>improved</em> readability of Flash sites, this still isn&#8217;t enough compared to a well-made HTML website.</li>
<li><strong>There are no links</strong>. If you want to send a link to a friend &#8211; no dice. If Google actually learns how to crawl such websites, what links is the crawler going to give? There is only one URL in such a site &#8211; the domain name. Best case scenario in Google listings would be a single-page website with a lot of heterogeneous information</li>
<li>The web is all about <strong>content over design</strong> not vice versa. Traditional technologies today are so good that what people usually do with Flash ( and can&#8217;t with other stuff ) is make something which looks more like an art gallery than a website. This is extremely counter-productive for any business &#8211; end-users visit a site not to experience eye-candies but to get some content. Just like a fashion review &#8211; you need to pay attention to the clothes, not to the models. The focus should stay on the content and not on the decoration. Period.</li>
<li><strong>Browsers are not really made for that</strong>. Yes, you know what I am talking about &#8211; when I go to a site and have to wait 7-10 secs just for the Flash to load and then start-up, this makes me a bit nervous. And as I have previously <a  href="http://www.ovalpixels.com/blog/2008/11/15/building-fast-web-sites-with-yahoos-exceptional-performance-team/" target="_blank">stated</a> on this blog, loading time is crucial for web visitors. Each second can be costly.</li>
<li><strong>Background music. </strong>Well, OK, it may be just me but I <em>hate</em> background music. Yes, I can stop it but I didn&#8217;t want it in the first place! I have 10 tabs running right now and I really don&#8217;t want some strange music streaming from somewhere without even notifying me. Yes, this is not just a Flash flaw but it looks like it is easy enough for Flash designers to get tempted by this option.</li>
<li><strong>&#8220;Let&#8217;s reinvent the web!</strong>&#8221; Hmmm&#8230; this sounds a bit like Microsoft but it is actually Adobe trying to do it. Correct me, if I am wrong, but isn&#8217;t &#8220;flashy&#8221; a bad term for a website? You get crazy, incoherent navigation, strange things popping out of nowhere, all kinds of elements moving, resizing and changing shapes all over the place. Long live vector animation! But wait, where did the visitor go&#8230; ?</li>
</ul>
<p style="64.125px;">I am sure you can think of many more reasons not to prefer Flash but these were my top list. These are also not too technical &#8211; we could talk about inter-compatibility with other technologies for too long.</p>
<p style="64.125px;">Enough ranting already &#8211; I will show you some tricks which can make Flash history. Our goal is to create a website which is <strong>both visually compelling and SEO-friendly</strong> &#8211; a simple 5-pager with some help from PHP.</p>
<h3>Back to basics</h3>
<p style="64.125px;">Good &#8216;ol Javascript. It needs some polishing from a well-known library, of course &#8211; otherwise you risk banging your head against the wall for some time. In short, we will use traditional html + css + javascript technology which will help us get some really nice effects. We will then add some nifty AJAX to maintain a good and flowing experience for the user but still making a SEO-friendly site with active links and most importantly &#8211; a graceful degradation. If the visitor is using a stone age computer without JS support ( or is simply using some JS blocking browser extension ), they will <em>still</em> be able to get to the content. They won&#8217;t experience all the sweetness but they will get what they wanted after all &#8211; the content.</p>
<h3>Javascript Libraries</h3>
<p>You can find <a  href="http://edevil.wordpress.com/2005/11/14/javascript-libraries-roundup/" target="_blank">tons</a> of them out there. I have personally used PrototypeJS and jQuery but have had a good look at YUI, MooTools and Rico, too. Good things are told about Dojo, but I haven&#8217;t really looked into it. Some time ago jQuery was much lighter than PrototypeJS and that made many people switch. Today the difference is not so great as jQuery can get down to ~18k and PrototypeJS to ~20k ( gzipped and minified ) but let&#8217;s not forget that PrototypeJS&#8217; effects&#8217; library Scriptaculous ( scriptaculous and effects only &#8211; no builder, slider, sound, controls and drag&amp;drop ) add another 15k. So, jQuery turns out to be twice lighter.</p>
<p>So, I chose</p>
<h4>jQuery</h4>
<p>Go get the most recent version from <a  href="http://code.google.com/p/jqueryjs/" target="_blank">here</a>. The version I am going t use is 1.3.2  as it is the most recent right now. And some additional plugins &#8211; we will talk more about them later but I can recommend <a  href="http://plugins.jquery.com/project/color" target="_blank">Color</a>, <a  href="http://plugins.jquery.com/project/timers" target="_blank">Timers</a> and <a  href="http://plugins.jquery.com/project/fxqueues" target="_blank">fxQueue</a>. The first one gives you the ability to smoothly change colors ( including background and border ) of elements via animate(). I am taking a minimalistic approach and some may argue that the Color plugin is not that much needed, but if we want some candies, we&#8217;ll have to use it. The Timers plugin is not an overkill either &#8211; it is a nice wrapper for setTimeout() and setInterval() and does some good garbage collection so that no memory leaks from the browser. You can, of course, use a variety of great plugins from <a  href="http://plugins.jquery.com/" target="_blank">jQuery&#8217;s plugins&#8217; repository</a>.</p>
<p>And because this post is getting too long, I will begin with the actual stuff in my next blog entry &#8211; stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ovalpixels.com/blog/2009/02/20/making-fancy-websites-without-flash-introduction/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CakePHP Migrations without PEAR</title>
		<link>http://www.ovalpixels.com/blog/2008/11/17/cakephp-migrations-without-pear/</link>
		<comments>http://www.ovalpixels.com/blog/2008/11/17/cakephp-migrations-without-pear/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 21:19:31 +0000</pubDate>
		<dc:creator>georgi</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Bakery Joel Moss]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Chris Wanstrath]]></category>
		<category><![CDATA[installed applications]]></category>
		<category><![CDATA[Joel Moss]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.ovalpixels.com/blog/?p=67</guid>
		<description><![CDATA[Rails fans out there? It is no secret that CakePHP was born to implement the ideas of Ruby on Rails to the world of PHP &#8211; wonderful ideas, indeed, and I think we should pay tribute to the guys at 37signals. But what CakePHP still lacks, in my opinion, is pure and complete DB abstraction. [...]]]></description>
			<content:encoded><![CDATA[<h3>Rails fans out there?</h3>
<p>It is no secret that CakePHP was born to implement the ideas of Ruby on Rails to the world of PHP &#8211; wonderful ideas, indeed, and I think we should pay tribute to the guys at 37signals.</p>
<p>But what CakePHP still lacks, in my opinion, is pure and complete DB abstraction. It is true that most recent versions of Cake ( v.2 RC3 as of now ) have done a lot in that area &#8211; the framework is now strongly decoupled from MySQL, although I personally have never heard of study cases that use Oracle, for example.</p>
<p>To the point &#8211; in a multi-developer environment it is critical to have a versioning control system ( you know you should be using <a  href="http://git.or.cz" target="_blank">git</a>, right? ) and a database &#8216;versioning&#8217; system &#8211; that is where Rails is much more powerful than CakePHP &#8211; it has <strong>database migrations</strong>.<span id="more-67"></span></p>
<h3>Some migrations&#8217; background</h3>
<p>If you know what migrations are &#8211; skip that part and go directly to the next one. Otherwise &#8211; here is a simple explanation: they are related to the database like git ( or svn or cvs ) is related to the source. They simple provide a way to go back or forth to a previous or succeeding state ( or version ) of the database schema. The features of migrations are:</p>
<ul>
<li>They are DB agnostic &#8211; this means that they are not affected by the type of the DB server you&#8217;re using and help you in deploying your apps on different environments</li>
<li>They help you with your agile development &#8211; you can put info in and out without affecting the rest of the project</li>
<li>They provide you with a quick way to revert back to a previous state of the DB in case something went wrong</li>
<li>DB migrations can save your life if you work in a team</li>
</ul>
<p>To illustrate the all said, I have a simple example: You create a blog ( of course a blog &#8211; that&#8217;s probably the most often used example in the world ). Let&#8217;s split the development into three simple parts &#8211; development of blog posts CRUD; adding ACL; adding Comments to posts and.. that&#8217;s it &#8211; we want a simple example, after all.</p>
<p>So, first &#8211; blog posts Create, Read, Update, Delete. You begin by creating your DB schema. You need a simple posts&#8217; table with a few fields &#8211; id, title, body, created. Then you write your PHP code, of course ( out of scope here ).</p>
<p>But one beautiful day you decide more than one person should be able to add posts and modify their own posts only &#8211; that&#8217;s when you read about Access Control Lists. Now you need a few more tables &#8211; users, aros, acos, acl and you need to add a field to the posts&#8217; table ( user_id, for example ). Our small blog is getting just a bit more complex.</p>
<p>Finally, you want comments! But you have no time and ask your cousin for a favor ( he is a good dev, after all ). He adds another table for that. And then decides only registered users ( who cannot write new posts ) can add comments. And, of course, writes some more code. And inserts some more data in the db.</p>
<p>You ( and your cousin ) have went through 3 distinctive phases of agile development. You have, of course, used git ( oh, well, maybe svn or cvs ) to keep track of your code and make sure everything is ok and that you can revert back to a previous, stable version, if anything goes wrong. But then, one day &#8211; something really goes wrong. And you need to revert from state 3 to state 2 &#8211; i.e. remove the comments. But &#8230; your cousin is</p>
<ul>
<li> out of town</li>
<li>mad at you because you behaved badly on his last birthday party</li>
<li>has no idea what he did for you so many months ago</li>
</ul>
<p>No problem &#8211; you use your source versioning system and do the reversal. But.. something is still wrong &#8211; your database stays unchanged. What did you add from v2 to v3? Did you remove something? And you know nothing about Database Server X &#8211; can you write the SQLs to revert the schema?</p>
<p>That is where DB migrations come in and save your life. Well, maybe not that important with your blog but imagine 100+ development iterations and 10+ developers working simultaneously on your project and maintaining it on many different platforms &#8211; this can turn into a <em>small</em> nightmare.</p>
<h3>Joel Moss and his migrations</h3>
<p>In his <a  href="http://bakery.cakephp.org/articles/view/cake-db-migrations-v2-1">article</a> at the Bakery Joel Moss describes how to use his CakePHP migrations shell. Although that project was my inspiration and I highly respect his work, his approach has several drawbacks:</p>
<ul>
<li>it uses PEAR &#8211; I don&#8217;t like it &#8211; that&#8217;s why I use CakePHP. I do not find necessary to explain this &#8211; I guess it is highly subjective.</li>
<li>it is non-modular &#8211; you cannot use it to deploy applications &#8211; it is just a shell with no &#8216;core&#8217;</li>
<li>it cannot make a snapshot of your already existing schema &#8211; you haven&#8217;t used migrations yet? That&#8217;s something you will need.</li>
<li>it cannot merge your tables &#8211; that can be crucial when you already have different versions of the schema on different platforms and you just want them all to be standardized</li>
</ul>
<p>So, I proudly present you with</p>
<h3>My CakePHP Yaml Migrations and Fixtures</h3>
<p>The idea was born when <a  href="http://pagebakers.nl" target="_blank">Eelco</a> and I started working on PagebakeryCMS some time ago and was later further developed when we decided we needed a standardized CakePHP App Installer. You can get a <a  href="http://github.com/georgious/cakephp-yaml-migrations-and-fixtures" target="_blank">copy</a> of the project and follow it, too. What I personally find useful in it:</p>
<ul>
<li>no external libraries &#8211; only the SPYC class used to parse YAML files ( that is authored by Chris Wanstrath )</li>
<li>can easily complement your source versioning system &#8211; use it for team collaboration</li>
<li>can be used for DB abstraction installers &#8211; when deploying your applications on different platforms you don&#8217;t want to modify your SQLs &#8211; and the project is DB agnostic. The package also has fixtures ( well, the terms is not used correctly &#8211; this is for adding initial data to your database )</li>
<li>can be used to standardize already installed applications on different platforms</li>
<li>can help you make your apps DB agnostic by generating a YAML structure of your schema from where you can go on with the agnostic aproach</li>
</ul>
<h4>How it works</h4>
<p>Just put all files in your CakePHP vendors folder.</p>
<p>If you want to use the API only, simply include the classes in your code</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">App<span style="color: #339933;">::</span><span style="color: #004000;">Import</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'vendor'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'migrations'</span> <span style="color: #009900;">&#41;</span></pre></div></div>

<p>and/or</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">App<span style="color: #339933;">::</span><span style="color: #004000;">Import</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'vendor'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fixtures'</span> <span style="color: #009900;">&#41;</span></pre></div></div>

<p>And then, for example</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$migrations</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Migrations<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$migrations</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>load<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'comments.yml'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$migrations</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>up<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>For more usages &#8211; dig into the code a bit <img src='http://www.ovalpixels.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.ovalpixels.com/blog/2008/11/17/cakephp-migrations-without-pear/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Building fast web sites with Yahoo!&#8217;s Exceptional Performance Team</title>
		<link>http://www.ovalpixels.com/blog/2008/11/15/building-fast-web-sites-with-yahoos-exceptional-performance-team/</link>
		<comments>http://www.ovalpixels.com/blog/2008/11/15/building-fast-web-sites-with-yahoos-exceptional-performance-team/#comments</comments>
		<pubDate>Sat, 15 Nov 2008 01:50:59 +0000</pubDate>
		<dc:creator>georgi</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[faulty software]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP algorithms]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Steve Souders]]></category>
		<category><![CDATA[web designers]]></category>
		<category><![CDATA[web performance]]></category>
		<category><![CDATA[Yahoo!]]></category>

		<guid isPermaLink="false">http://www.ovalpixels.com/blog/?p=19</guid>
		<description><![CDATA[Yahoo!&#8217;s Developer Theater has always been a priceless resource for web designers and developers. But what I have found the most useful video for me was Steve Souders&#8217; High performance websites presentation. For those of you who don&#8217;t have the time to watch the whole video &#8211; here is a short summary. Like many things [...]]]></description>
			<content:encoded><![CDATA[<p>Yahoo!&#8217;s Developer Theater has always been a priceless resource for web designers and developers. But what I have found the most useful video for me was Steve Souders&#8217; <a  href="http://video.yahoo.com/watch/1040890/3880720" target="_blank">High performance websites</a> presentation. For those of you who don&#8217;t have the time to watch the whole video &#8211; here is a short summary.</p>
<p>Like many things in our Universe, web performance obeys Pareto&#8217;s 80-20 principle &#8211; 20% of the elements of a website cause 80% of the effects on the performance. And if we try to slightly reduce the time spent on loading those 20% of the elements, we can get much more than 20% increase in speed.<span id="more-19"></span></p>
<h3>Are servers the root of all evil?</h3>
<p>And as most of you probably already guessed &#8211; most of the server-side elements are not within those 20%. If you slightly improve ( or think you have ) your PHP algorithms or your SQL queries, you will probably gain benefits which are close to the statistical error. ( Here we are not talking about drastic changes or bug fixes in faulty software which shouldn&#8217;t have been there in the first place ).</p>
<h3>Speed up the browser</h3>
<p>What turns out to have the greatest impact on loading times and user experiences are the elements which load into the browser. And writing speed enhancements for the browser is out of our scope right now &#8211; we can just try to adapt our web pages, so that it is easier for it to parse and display. Here are my top 5 rules which have given me fantastic results.</p>
<h4>Number of HTTP requests</h4>
<p>If we are to believe Yahoo!, 80% of the time spent loading a web page is taken by downloading the entities of that page &#8211; mainly css, javascripts and images. The problem here is that we have too much unimportant (for the users) data sent back and forth, also known as <em>headers</em>. Even the smallest image has its request and response headers traveling with it across the Net. So, my advice is &#8211; combine your javascript and css files and use css sprites&#8217; images. These are image maps which hold all of your images in one file and thus only this single file is sent over with its headers. Read more on css sprites <a  href="http://alistapart.com/articles/sprites" target="_blank">here</a>.</p>
<h4>Expires header</h4>
<p>This technique is very simple, yet very powerful and rarely used. Expires headers tell the browser that the entity it has requested *will not be changed* until some date. In practice, this means that the browser will not download that entity, if it already has it in its cache &#8211; 0 bytes transfered. Be careful, though, if you need to change something on the fly ( especially when still developing a site ), you will have to change the name of that file, so that the browser doesn&#8217;t think it already has it in the cache. This can easily be avoided using a simple versioning technique ( a link to some-file.js can look like some-file.js?version=1.0 and can later be changed to some-file.js?version=1.1 which will instantly make the browser fetch the file again as the url has changed ).</p>
<p>So, here &#8211; simply set a far-future Expires header on static content.</p>
<h4>GZip</h4>
<p>Also very useful, especially on large text files (like css and javascript files). This will effectively compress your content on the server, then send it to the browser which will uncompress it and use it. But be careful &#8211; don&#8217;t use this on images as it can be counter-productive. All A grade browsers support gzipped responses, so no worries about compatibility here.</p>
<h4>Javascript and CSS</h4>
<p>You should already know this but just in case &#8211; compress and minify your javascript and css files; put css at the top and javascript at the bottom. Simple, heh?</p>
<h4>Flush it!</h4>
<p>Well, the only server-side technique in my top 5 &#8211; flush your output buffer early ( just after the &lt;head&gt; tag ). This is very helpful on sites rich in html and text content because it will send the &lt;head&gt; of the html document fast enough so that the browser may start downloading the respective css files ( which you have put in the head, as described in the previous rule ) and underlying css images before the rest of the document has been transfered. Otherwise, you may end up in a situation where the whole HTML document needs to be received before css and the images can start being fetched.</p>
<p>This is just a sneak overview of the techniques &#8211; for a thorough list and technical help, please visit <a  href="http://developer.yahoo.com/performance/rules.html" target="_blank">yahoo&#8217;s site</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ovalpixels.com/blog/2008/11/15/building-fast-web-sites-with-yahoos-exceptional-performance-team/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

