<?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>Saturnboy &#187; design</title>
	<atom:link href="http://saturnboy.com/tag/design/feed/" rel="self" type="application/rss+xml" />
	<link>http://saturnboy.com</link>
	<description>Code, Work, and Life</description>
	<lastBuildDate>Wed, 28 Jul 2010 13:20:37 +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>Building Flex 4 Containers with Multiple Content Areas</title>
		<link>http://saturnboy.com/2010/07/multiple-content-area-containers/</link>
		<comments>http://saturnboy.com/2010/07/multiple-content-area-containers/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 22:48:18 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[custom component]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[flex4]]></category>
		<category><![CDATA[skinning]]></category>

		<guid isPermaLink="false">http://saturnboy.com/?p=1454</guid>
		<description><![CDATA[Back in the days of Flex 3, if you wanted multiple content areas in your main application, you&#8217;d need to arrange some set of containers (Canvas, HBox, VBox) in the app and fill them with content. It was just your basic Flex 3 development process. The danger, of course, is that you are mixing content [...]]]></description>
			<content:encoded><![CDATA[<p>Back in the days of Flex 3, if you wanted multiple content areas in your main application, you&#8217;d need to arrange some set of containers (<code>Canvas</code>, <code>HBox</code>, <code>VBox</code>) in the app and fill them with content.  It was just your basic Flex 3 development process.  The danger, of course, is that you are mixing content with presentation, aka bad separation of concerns.  Today, with the power of Flex 4 skins, we can avoid this issue by moving the presentation layer into a skin (or set of skins).  And thus, we can do a much better job achieving a happy level of separation of concerns.</p>
<h3>The Flex 3 Way</h3>
<p class="bottom">To give a concrete example, I&#8217;ll build a blog layout (yes, another blog layout) with a header, footer, sidebar, and main content areas.  But before we get started, let&#8217;s review the old Flex 3 way:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:HBox</span> id=<span style="color: #ff0000;">&quot;header&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Image</span> source=<span style="color: #ff0000;">&quot;@Embed('assets/logo.png')&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:HBox</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Canvas</span> id=<span style="color: #ff0000;">&quot;body&quot;</span> width=<span style="color: #ff0000;">&quot;800&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Text</span> text=<span style="color: #ff0000;">&quot;main content&quot;</span> width=<span style="color: #ff0000;">&quot;600&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:VBox</span> id=<span style="color: #ff0000;">&quot;sidebar&quot;</span> x=<span style="color: #ff0000;">&quot;600&quot;</span> width=<span style="color: #ff0000;">&quot;200&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Text</span> text=<span style="color: #ff0000;">&quot;Sidebar&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Text</span> text=<span style="color: #ff0000;">&quot;sidebar content&quot;</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:VBox</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Canvas</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:VBox</span> id=<span style="color: #ff0000;">&quot;footer&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Text</span> text=<span style="color: #ff0000;">&quot;2010 saturnboy&quot;</span> styleName=<span style="color: #ff0000;">&quot;footer&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:VBox</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>The above code comes from a previous post, <a href="http://saturnboy.com/2009/02/designing-in-flex/">Designing in Flex 3</a>, but has been modified to make sense here.  You&#8217;ve got you basic blog design: a box for the header, footer, and body, where body is subsequently is divided into a main content area and a sidebar.</p>
<h3>The 3-in-4 Way, aka The Wrong Way</h3>
<p>The unfortunate next step in a Flex developer&#8217;s evolution is what I like to call the Flex 3-in-4 way.  This is a the way of neanderthals,  which is to say, it is an evolutionary dead end.  If you ever have the bad luck to see 3-in-4 code, you can be sure you are dealing with a novice Flex 4 developer.  In general, the 3-in-4 way consists of making the simple transcription: <code>Canvas</code> &rarr; <code>Group</code>, <code>HBox</code> &rarr; <code>HGroup</code>, <code>VBox</code> &rarr; <code>VGroup</code>.  But the most damning tipoff of a 3-in-4 developer is the assertion that one is now a Flex 4 developer and the learning curve wasn&#8217;t all that bad.  While I do think Flex 4 is more of an evolutionary release than a revolutionary release, it&#8217;s different enough.  And it is particularly different on the design side of the framework, how it handles skins, layout, etc.</p>
<p class="bottom">If we just transcribe the above example, we get some classic 3-in-4 code:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;s:HGroup</span> id=<span style="color: #ff0000;">&quot;header&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;Multi Content Area Example&quot;</span> styleName=<span style="color: #ff0000;">&quot;header&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:HGroup</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Group</span> id=<span style="color: #ff0000;">&quot;body&quot;</span> width=<span style="color: #ff0000;">&quot;800&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;main content&quot;</span> width=<span style="color: #ff0000;">&quot;600&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VGroup</span> x=<span style="color: #ff0000;">&quot;600&quot;</span> width=<span style="color: #ff0000;">&quot;200&quot;</span> styleName=<span style="color: #ff0000;">&quot;sidebarBox&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;Sidebar&quot;</span> styleName=<span style="color: #ff0000;">&quot;title&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;sidebar content&quot;</span> styleName=<span style="color: #ff0000;">&quot;sidebar&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:VGroup</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Group</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VGroup</span> id=<span style="color: #ff0000;">&quot;footer&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;2010 saturnboy&quot;</span> styleName=<span style="color: #ff0000;">&quot;footer&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:VGroup</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>*Barf*, please <b>not</b> do this.  This code has all the same issues as the Flex 3 code in the first example, and moreover it is a slap in the face of <i>The Flex 4 Way</i> and all of its improvements.</p>
<h3>The Flex 4 Way</h3>
<p>Yes, there is a Flex 4 Way and it looks like this.</p>
<p class="bottom">First, we rewrite the main app using a custom container.  Ignoring the specifics of the custom container for a moment, here is the re-written main app (minus some clutter):</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;containers:headerContent</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;Multi Content Area Example&quot;</span> styleName=<span style="color: #ff0000;">&quot;header&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/containers:headerContent</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;containers:sidebarContent</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:RichText</span> left=<span style="color: #ff0000;">&quot;0&quot;</span> right=<span style="color: #ff0000;">&quot;0&quot;</span> styleName=<span style="color: #ff0000;">&quot;sidebar&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:content</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:p</span> fontSize=<span style="color: #ff0000;">&quot;20&quot;</span><span style="color: #7400FF;">&gt;</span></span>Sidebar<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:p</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:p</span><span style="color: #7400FF;">&gt;</span></span>sidebar content<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:p</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:content</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:RichText</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/containers:sidebarContent</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;containers:footerContent</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;2010 saturnboy&quot;</span> styleName=<span style="color: #ff0000;">&quot;footer&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/containers:footerContent</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:RichText</span> left=<span style="color: #ff0000;">&quot;0&quot;</span> right=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:content</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:p</span> fontSize=<span style="color: #ff0000;">&quot;30&quot;</span><span style="color: #7400FF;">&gt;</span></span>Content<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:p</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:p</span><span style="color: #7400FF;">&gt;</span></span>main content<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:p</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:content</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:RichText</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>As you can see, the main app is now a nice set of semantic buckets, one for each of the content areas.  Header stuff goes in the <code>headerContent</code> bucket, footer stuff goes in the <code>footerContent</code> bucket, etc.</p>
<h3>Building a Multi Content Area Container</h3>
<p>Second, we need to create a custom container with the nice set of semantic buckets used in the above code.  This is achieved by following a straightforward formula:</p>
<ol>
<li><b>Extend SkinnableContainer</b> &ndash; Extend <code>SkinnableContainer</code> or some child class.  In our sample app, our custom container extends <code>Application</code> (which extends <code>SkinnableContainer</code>).</li>
<li><b>Add Buckets</b> &ndash; add some content buckets (in the form of <i>xxx</i><code>Content</code>) as <code>Array</code>s.  These become the MXML tags used to bucket components together.  Each content bucket has a public getter, but most importantly a public setter that accepts an incoming <code>Array</code> of <code>IVisualElement</code>s and uses the magical <code>mxmlContent</code> property to assign it to the associated <code>SkinPart</code>.</li>
<li><b>Add SkinParts</b> &ndash; add some matching SkinParts (in the form of <i>xxx</i><code>Group</code>) as spark <code>Group</code>s.  There are used in the custom skin to display the content.  Also, I usually set <code>required=&quot;false&quot;</code> to make everything optional.</li>
<li><b>Add partAdded() &amp; partRemoved()</b> &ndash; override the new Flex 4 skinning lifecycle methods to wire the incoming content to the outgoing <code>SkinPart</code>.</li>
</ol>
<p class="bottom">The custom component code is actually easier to follow then the description.  Here is a custom container with only one additional content bucket, <code>sidebarContent</code>, and its matching <code>SkinPart</code>, <code>sidebarGroup</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package containers <span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">import</span> spark.<span style="color: #006600;">components</span>.<span style="color: #006600;">Group</span>;
    <span style="color: #0066CC;">import</span> spark.<span style="color: #006600;">components</span>.<span style="color: #006600;">Application</span>;
&nbsp;
    <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MainApp <span style="color: #0066CC;">extends</span> Application <span style="color: #66cc66;">&#123;</span>
        <span style="color: #66cc66;">&#91;</span>SkinPart<span style="color: #66cc66;">&#40;</span>required=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
        <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> sidebarGroup:Group;
&nbsp;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _sidebarContent:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;
&nbsp;
        <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> MainApp<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #66cc66;">&#91;</span>ArrayElementType<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;mx.core.IVisualElement&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
        <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> sidebarContent<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Array</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #b1b100;">return</span> _sidebarContent;
        <span style="color: #66cc66;">&#125;</span>
        <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> sidebarContent<span style="color: #66cc66;">&#40;</span>value:<span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
            _sidebarContent = value;
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>sidebarGroup<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                sidebarGroup.<span style="color: #006600;">mxmlContent</span> = value;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        override protected <span style="color: #000000; font-weight: bold;">function</span> partAdded<span style="color: #66cc66;">&#40;</span>partName:<span style="color: #0066CC;">String</span>, instance:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #0066CC;">super</span>.<span style="color: #006600;">partAdded</span><span style="color: #66cc66;">&#40;</span>partName, instance<span style="color: #66cc66;">&#41;</span>;
&nbsp;
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>instance == sidebarGroup<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                sidebarGroup.<span style="color: #006600;">mxmlContent</span> = _sidebarContent;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        override protected <span style="color: #000000; font-weight: bold;">function</span> partRemoved<span style="color: #66cc66;">&#40;</span>partName:<span style="color: #0066CC;">String</span>, instance:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #0066CC;">super</span>.<span style="color: #006600;">partRemoved</span><span style="color: #66cc66;">&#40;</span>partName, instance<span style="color: #66cc66;">&#41;</span>;
&nbsp;
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>instance == sidebarGroup<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                sidebarGroup.<span style="color: #006600;">mxmlContent</span> = <span style="color: #000000; font-weight: bold;">null</span>;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Following the four steps: we extend <code>Application</code>, have a <code>sidebarContent</code> bucket and its associated <code>sidebarGroup</code> <code>SkinPart</code>, and override <code>partAdded()</code> and <code>partRemoved()</code> to wire everything together.</p>
<h3>Skinning a Multi Content Area Container</h3>
<p>Skinning in Flex 4 is awesome, and like everyone says, it&#8217;s easily one of the best new features in the framework.  While I find the skinning process fairly straightforward, I would never call it trivial, mostly due to the depth and flexibility of the skinning system.</p>
<p>We need a custom skin for our custom multi content area component.  This is probably the 10% case for skinning, but it&#8217;s also the coolest.  In my experience, an average Flex 4 app has many <code>Button</code> skins (like 10 or even 20), a few default component skins (skins for <code>List</code>, <code>DropDownList</code>, <code>TextInput</code>, etc.), and maybe only two or three skins for custom components.</p>
<p>The skin itself is nothing special.  To display our custom component&#8217;s <code>SkinPart</code>s, we simply include a <code>Group</code> with the matching <code>id</code> attribute.  For example, our skin will include a <code>&lt;s:Group id="sidebarGroup" /&gt;</code> to display the <code>sidebarGroup</code> <code>SkinPart</code>.  Just rinse, wash, repeat, to add all of our custom content areas in the container to the skin.</p>
<p class="bottom">Here is a trivial skin:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Skin</span> ... <span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Metadata</span><span style="color: #7400FF;">&gt;</span></span>
        [HostComponent(&quot;containers.MainApp&quot;)]
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Metadata</span><span style="color: #7400FF;">&gt;</span></span> 
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:states</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;normal&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;disabled&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:states</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VGroup</span> left=<span style="color: #ff0000;">&quot;40&quot;</span> right=<span style="color: #ff0000;">&quot;40&quot;</span> top=<span style="color: #ff0000;">&quot;40&quot;</span> bottom=<span style="color: #ff0000;">&quot;40&quot;</span> gap=<span style="color: #ff0000;">&quot;20&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Group</span> id=<span style="color: #ff0000;">&quot;headerGroup&quot;</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Group</span> id=<span style="color: #ff0000;">&quot;contentGroup&quot;</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Group</span> id=<span style="color: #ff0000;">&quot;sidebarGroup&quot;</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Group</span> id=<span style="color: #ff0000;">&quot;footerGroup&quot;</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:VGroup</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Skin</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>In this trivial skin, we just shove all the content groups (including <code>SkinnableContainer</code>&#8216;s default <code>Group</code>, <code>contentGroup</code>) into a <code>VGroup</code>.  Also note, we correctly set <code>HostComponent</code> to our custom container.  If you are thinking, &quot;Hey, this skin looks similar to the Flex 3 and 3-in-4 example code, just minus the content&quot; that&#8217;s exactly the point.</p>
<p class="bottom">Lastly, we wire out skin to our custom component via CSS:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">containers|MainApp <span style="color: #00AA00;">&#123;</span>
    skinClass<span style="color: #00AA00;">:</span>ClassReference<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'skins.TrivialAppSkin'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Using <code>skinClass</code> to wire a skin to a component is <b>so</b> 2009.  The sample app has its CSS inline, but in any real app I&#8217;ll always put this in an external file.</p>
<h3>Conclusion</h3>
<p>After this, there&#8217;s really not much more to say.  You can certainly create a more complicated arrangement of the multiple content areas by making a more complicated skin.  I&#8217;ve done exactly this in the final sample, which includes three different skins and a skin switcher (click 1, 2, or 3 to switch skins).</p>
<p>&raquo; <a href="http://saturnboy.com/proj/flex4/multi_content_area/MultiContentArea.html">view MultiConentArea sample</a> (view source enabled)</p>
<h5>Files</h5>
<ul>
<li><a href="http://saturnboy.com/proj/flex4/multi_content_area/MultiContentArea.html">MultiContentArea</a> (<a href="http://saturnboy.com/proj/flex4/multi_content_area/srcview/MultiContentArea.zip">download</a>)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://saturnboy.com/2010/07/multiple-content-area-containers/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Perfect Gradients for Perfect Buttons</title>
		<link>http://saturnboy.com/2010/05/perfect-gradients-perfect-buttons/</link>
		<comments>http://saturnboy.com/2010/05/perfect-gradients-perfect-buttons/#comments</comments>
		<pubDate>Tue, 11 May 2010 03:21:02 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://saturnboy.com/?p=1334</guid>
		<description><![CDATA[Photoshop does this annoying thing where purely vertical gradients have some horizontal variation. Yes, it&#8217;s usually only plus or minus one bit of color, but it offends! I&#8217;ve battled Photoshop for a while on this, but I just can&#8217;t seem to get exactly what I want out of it. So to make a perfect gradient, [...]]]></description>
			<content:encoded><![CDATA[<p>Photoshop does this annoying thing where purely vertical gradients have some horizontal variation.  Yes, it&#8217;s usually only plus or minus one bit of color, but it offends!  I&#8217;ve battled Photoshop for a while on this, but I just can&#8217;t seem to get <b>exactly</b> what I want out of it.  So to make a perfect gradient, I decided to write some code.  The requirements are simple: given a starting color and a set of deltas, output a perfect gradient.</p>
<p class="bottom">Here are some quick examples:</p>
<div class="span-14 last">
<div class="span-1 comm-idx">1</div>
<div class="span-3">
<img src="http://saturnboy.com/proj/php/perfect_gradient/gradient1.png" alt="gradient1" title="gradient1" width="60" height="100" />
</div>
<div class="prepend-1 span-1 comm-idx">2</div>
<div class="span-3">
<img src="http://saturnboy.com/proj/php/perfect_gradient/gradient2.png" alt="gradient2" title="gradient2" width="60" height="100" />
</div>
<div class="prepend-1 span-1 comm-idx">3</div>
<div class="span-3 last">
<img src="http://saturnboy.com/proj/php/perfect_gradient/gradient3.png" alt="gradient3" title="gradient3" width="60" height="100" />
</div>
</div>
<div class="span-14 last">
<div class="prepend-1 span-3"><b>#000000</b><br />4, 1, 0.25</div>
<div class="prepend-2 span-3"><b>#eeeeff</b><br />-2.2, -1, -0.3</div>
<div class="prepend-2 span-3 last"><b>#ff0099</b><br />-1, 0, 1</div>
</div>
<div class="span-14 last">&nbsp;</div>
<p class="bottom">If we zoom in on example #1, which starts with black (#000000) and has deltas of 4, 1, 0.25, we see the following:</p>
<div class="prepend-1 span-13 last">
<img src="http://saturnboy.com/proj/php/perfect_gradient/gradient-diagram.png" alt="zoomed gradient" title="zoomed gradient" width="252" height="200" />
</div>
<div class="span-14 last">&nbsp;</div>
<p>The diagram shows the first ten rows of the gradient.  The delta values are accumulated with each row, and only the whole part of the resulting color value is used (aka I take the <b>floor</b> of each color bit).  So in this example, using the fractional delta of 0.25 results in exactly one additional blue bit every four rows.  Ahhh, perfect!</p>
<h3>The Code</h3>
<p class="bottom">No need to <a href="http://saturnboy.com/2010/04/the-schizophrenic-programmer/">use some fancy new language</a>, I wrote a simple PHP program to handle commandline input and output a perfect PNG gradient.  The interesting part is the function that generates and saves the gradient:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> build_image<span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #339933;">,</span> <span style="color: #000088;">$w</span><span style="color: #339933;">,</span> <span style="color: #000088;">$h</span><span style="color: #339933;">,</span> <span style="color: #000088;">$color</span><span style="color: #339933;">,</span> <span style="color: #000088;">$delta</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$img</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatetruecolor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$w</span><span style="color: #339933;">,</span> <span style="color: #000088;">$h</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecolorallocate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$img</span><span style="color: #339933;">,</span> <span style="color: #000088;">$color</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$color</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$color</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$d</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$delta</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$y</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$y</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$h</span><span style="color: #339933;">;</span> <span style="color: #000088;">$y</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">imagefilledrectangle</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$img</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #000088;">$w</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecolorallocate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$img</span><span style="color: #339933;">,</span>
      clamp<span style="color: #009900;">&#40;</span><span style="color: #990000;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$color</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$d</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
      clamp<span style="color: #009900;">&#40;</span><span style="color: #990000;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$color</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$d</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
      clamp<span style="color: #009900;">&#40;</span><span style="color: #990000;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$color</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$d</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$d</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$d</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$delta</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$d</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$delta</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$d</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$delta</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #990000;">imagepng</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$img</span><span style="color: #339933;">,</span> <span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">imagedestroy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$img</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The code is straight forward.  First, create the image via <code>imagecreatetruecolor()</code>.  Then, starting with the starting color, draw a one pixel tall rectangle for each row of the image.  The next row&#8217;s color is computed in each iteration by adding the accumulated delta to the starting color.  Finally, output the image as a PNG via <code>imagepng()</code> and free the memory.  The complete php source can be downloaded <a href="http://saturnboy.com/proj/php/perfect_gradient/gradient.php.gz">here</a>.</p>
<h3>Button Time </h3>
<p>Once we have our perfect gradient engine in place, it&#8217;s time to make some perfect buttons.  To achieve the standard <i>glass button</i> look-and-feel, I typically fuse two gradients together: light on the top, dark on the bottom.</p>
<p class="bottom">Here are the two halves of a pretty red button, along with their starting color and deltas:</p>
<div class="span-14 last">
<div class="prepend-1 span-3 quiet">TOP</div>
<div class="prepend-2 span-3 last quiet">BOTTOM</div>
</div>
<div class="span-14 last">
<div class="prepend-1 span-3">
<img src="http://saturnboy.com/proj/php/perfect_gradient/red-top.png" alt="top" title="top" width="100" height="16" />
</div>
<div class="prepend-2 span-3 last">
<img src="http://saturnboy.com/proj/php/perfect_gradient/red-bottom.png" alt="bottom" title="bottom" width="100" height="16" />
</div>
</div>
<div class="span-14 last">
<div class="prepend-1 span-3"><b>#ff8080</b><br />-3,-3,-3</div>
<div class="prepend-2 span-3 last"><b>#d23c3c</b><br />-3,-3,-3</div>
</div>
<div class="span-14 last">&nbsp;</div>
<p class="bottom">And the two commandline invocations of <code>gradient.php</code> to create the gradients:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">php gradient.php 100x16 ff8080 -<span style="color: #000000;">3</span>,-<span style="color: #000000;">3</span>,-<span style="color: #000000;">3</span> top.png
php gradient.php 100x16 d23c3c -<span style="color: #000000;">3</span>,-<span style="color: #000000;">3</span>,-<span style="color: #000000;">3</span> bottom.png</pre></div></div>

<p>If I want my buttons to be sexy, rounded corners are a must.  My favorite photoshop trick to create multiple rounded buttons is to use a rounded alpha-transparent button with each gradient as a clipping mask.  Using a clipping mask is a simple way to guarantee button geometry remains fixed while colors are changed.</p>
<p class="bottom">Here is the layers pane showing the two gradients fused together and used as a clipping mask for the rounded alpha-transparent button:</p>
<div class="prepend-1 span-13 last">
<img src="http://saturnboy.com/proj/php/perfect_gradient/layers-dialog.png" alt="clip mask" title="clip mask" width="220" height="177" />
</div>
<div class="span-14 last">&nbsp;</div>
<p class="bottom">The result is a horizontally stretchable gradient button, that doesn&#8217;t look half bad.  See for yourself:</p>
<div class="prepend-1 span-13 last">
<img src="http://saturnboy.com/proj/php/perfect_gradient/btn-red.png" alt="button" title="button" width="26" height="32" />
</div>
<div class="span-14 last">&nbsp;</div>
<h3>Custom UIButton</h3>
<p class="bottom">The final button asset can be used as desired, but here is a simple Objective-C example since I&#8217;ve been in iPhone world lately:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">UIButton <span style="color: #002200;">*</span>btn <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIButton buttonWithType<span style="color: #002200;">:</span>UIButtonTypeCustom<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>btn setFrame<span style="color: #002200;">:</span>CGRectMake<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">20</span>, <span style="color: #2400d9;">20</span>, <span style="color: #2400d9;">140</span>, <span style="color: #2400d9;">32</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>btn setBackgroundImage<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;btn-red.png&quot;</span><span style="color: #002200;">&#93;</span>
      stretchableImageWithLeftCapWidth<span style="color: #002200;">:</span><span style="color: #2400d9;">10.0</span>
      topCapHeight<span style="color: #002200;">:</span><span style="color: #2400d9;">0.0</span><span style="color: #002200;">&#93;</span> forState<span style="color: #002200;">:</span>UIControlStateNormal<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>btn setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;BUTTON&quot;</span> forState<span style="color: #002200;">:</span>UIControlStateNormal<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>btn setTitleColor<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIColor whiteColor<span style="color: #002200;">&#93;</span> forState<span style="color: #002200;">:</span>UIControlStateNormal<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>btn.titleLabel setFont<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIFont boldSystemFontOfSize<span style="color: #002200;">:</span><span style="color: #2400d9;">14</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>Create a new <code>UIButton</code> of type <code>UIButtonTypeCustom</code> and then set the button skin as the <code>backgroundImage</code>.  The horizontal stretchability is due to the <code>stretchableImageWithLeftCapWidth</code> and <code>topCapHeight</code>.</p>
<p class="bottom">Here is a screenshot from the iPhone simulator showing the button in action:</p>
<div class="prepend-1 span-13 last">
<img src="http://saturnboy.com/proj/php/perfect_gradient/screenshot.png" alt="screenshot" title="screenshot" width="326" height="486" />
</div>
<div class="span-14 last">&nbsp;</div>
<h5>Files</h5>
<ul>
<li><a href="http://saturnboy.com/proj/php/perfect_gradient/gradient.php.gz">gradient.php</a> &ndash; the perfect gradient engine</li>
<li><a href="http://saturnboy.com/proj/php/perfect_gradient/gradient-button.psd">gradient-button.psd</a> &ndash; the photoshop source for the red button image, including the rounded alpha-transparent button and fused red gradients</li>
<li><a href="http://saturnboy.com/proj/php/perfect_gradient/btn-red.png">btn-red.png</a> &ndash; the red button image</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://saturnboy.com/2010/05/perfect-gradients-perfect-buttons/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Inkscape SVG to Degrafa Path</title>
		<link>http://saturnboy.com/2009/06/inkscape-svg-degrafa-path/</link>
		<comments>http://saturnboy.com/2009/06/inkscape-svg-degrafa-path/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 03:44:44 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[degrafa]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[inkscape]]></category>
		<category><![CDATA[svg]]></category>

		<guid isPermaLink="false">http://saturnboy.com/?p=528</guid>
		<description><![CDATA[Going from SVG data to a Degrafa Path couldn&#8217;t be easier: just copy &#38; paste. You can watch this video tutorial or you can check out this demo. But there is one trick for Inkscape: even though the coordinate origin on the Inkscape document is the normal cartesian origin in the bottom left and the [...]]]></description>
			<content:encoded><![CDATA[<p>Going from <a href="http://www.w3.org/TR/SVG/">SVG</a> data to a <a href="http://www.degrafa.org/">Degrafa</a> <code>Path</code> couldn&#8217;t be easier: just copy &amp; paste.  You can watch <a href="http://www.vimeo.com/1223682">this video tutorial</a> or you can check out <a href="http://www.degrafa.org/source/Car/Car.html">this demo</a>.</p>
<p><b>But there is one trick for <a href="http://www.inkscape.org/">Inkscape</a></b>: even though the coordinate origin on the Inkscape document is the normal cartesian origin in the bottom left and the y-axis points up, the SVG output always uses the upper left corner of the document as the origin and the y-axis points down (per the <a href="http://www.w3.org/TR/SVG/coords.html#InitialCoordinateSystem">SVG Spec, &sect; 7.3</a>).</p>
<p class="bottom">To demonstrate, I created a new document in Inkscape, set my dimensions to 500 x 500, and placed a simple path (which happens to be a square) in the upper left corner:</p>
<div class="span-14 top bottom last" style="min-height:453px;">
<img src="http://saturnboy.com/wp-content/uploads/2009/06/square.png" alt="square" title="square" width="459" height="443" />
</div>
<p>You can see by the rulers in Inkscape that the square&#8217;s origin is at (0,500).</p>
<p class="bottom">If we save our square and examine the SVG output, we see:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;svg</span> ...<span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;g</span> ...<span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;path</span> <span style="color: #000066;">d</span>=<span style="color: #ff0000;">&quot;M 0,0 L 100,0 L 100,100 L 0,100 L 0,0 z&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/g<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/svg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>If we ignore everything in the file except the relevant path data, we can see the very first path command is <code>M 0,0</code> which is path-speak for move to (0,0).  This is exactly as expected from the SVG spec: upper left <b>is</b> the coordinate origin.  <b>The cartesian origin in Inkscape is bogus!</b></p>
<p class="bottom">Next, we can just copy the path data from the SVG file and paste it into the <code>data</code> attribute of a Degrafa <code>Path</code> component.</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;Degrafa:Path</span> data=<span style="color: #ff0000;">&quot;M 0,0 L 100,0 L 100,100 L 0,100 L 0,0 z&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;Degrafa:fill</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;Degrafa:SolidFill</span> color=<span style="color: #ff0000;">&quot;#EECCEE&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/Degrafa:fill</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;Degrafa:stroke</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;Degrafa:SolidStroke</span> color=<span style="color: #ff0000;">&quot;#FF00FF&quot;</span> weight=<span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/Degrafa:stroke</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/Degrafa:Path</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>Give it a fill color and a stroke color, and we get a <a href="http://saturnboy.com/proj/degrafa_svg/degrafa_square/degrafa_square.html">pretty purple square</a>.  Now I know my Degrafa <code>Path</code> component will have a square in the upper left, because I know my square was in the upper left in Inkscape.  Nice and easy.</p>
<h5>Files</h5>
<ul>
<li><a href="http://saturnboy.com/wp-content/uploads/2009/06/square.svg">square.svg</a></li>
<li><a href="http://saturnboy.com/proj/degrafa_svg/degrafa_square/degrafa_square.html">Square</a> (<a href="http://saturnboy.com/proj/degrafa_svg/degrafa_square/srcview/degrafa_square.zip">download</a>)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://saturnboy.com/2009/06/inkscape-svg-degrafa-path/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Styling Flexlib&#8217;s WindowShade</title>
		<link>http://saturnboy.com/2009/03/styling-flexlib-windowshade/</link>
		<comments>http://saturnboy.com/2009/03/styling-flexlib-windowshade/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 05:45:03 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[flexlib]]></category>
		<category><![CDATA[skinning]]></category>

		<guid isPermaLink="false">http://saturnboy.com/?p=246</guid>
		<description><![CDATA[A while back I started digging into the WindowShade component in Flexlib. I really needed a set of cool collapsable buckets for a project at work, and WindowShade was perfect for the task. Alas, I couldn&#8217;t find too much info on styling a WindowShade other than Doug McCune&#8217;s awesome example of WindowShade and Degrafa. So, [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I started digging into the <a href="http://flexlib.googlecode.com/svn/trunk/docs/flexlib/containers/WindowShade.html">WindowShade</a> component in <a href="http://code.google.com/p/flexlib/">Flexlib</a>. I really needed a set of cool collapsable buckets for a project at <a href="http://www.gorillalogic.com/">work</a>, and WindowShade was perfect for the task.  Alas, I couldn&#8217;t find too much info on styling a WindowShade other than Doug McCune&#8217;s <a href="http://dougmccune.com/blog/2008/02/26/examples-from-my-360flex-session-using-open-source-community-projects/">awesome example of WindowShade and Degrafa</a>.  So, here is how I went about achieving the look and feel I needed with WindowShade.</p>
<h5>Plain Vanilla</h5>
<p>I started with an unstyled, super vanilla WindowShade wrapping a List.  And of course, I get this super-vanilla output:</p>
<p><a href="http://saturnboy.com/proj/shade/shade1/shade1.html">shade 1</a> (view source enabled)</p>
<p>The only styling magic was to add <code>padding="0"</code> to the WindowShade to get the child List component to suck up to the bottom of the WindowShade button.</p>
<h5>My First Attempt</h5>
<p class="bottom">In the next pass, I ditched the lame WindowShade button, and went with Flexlib&#8217;s <a href="http://flexlib.googlecode.com/svn/trunk/docs/flexlib/controls/CanvasButton.html">CanvasButton</a>, which contains a simple Label plus a CheckBox skinned with a plus or minus graphic. The code:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">        xmlns:flexlibContainer=<span style="color: #ff0000;">&quot;flexlib.containers.*&quot;</span></span>
<span style="color: #000000;">        xmlns:flexlibControl=<span style="color: #ff0000;">&quot;flexlib.controls.*&quot;</span></span>
<span style="color: #000000;">        viewSourceURL=<span style="color: #ff0000;">&quot;srcview/index.html&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">    &lt;![CDATA[</span>
<span style="color: #339933;">        [Bindable]</span>
<span style="color: #339933;">        private var goodies:Array = [</span>
<span style="color: #339933;">            { header:'Ice Cream', items:['Vanilla', 'Chocolate', 'Strawberry', 'Cookies &amp; Cream'] },</span>
<span style="color: #339933;">            { header:'Candy', items:['Twix', 'Snickers', 'Fire Balls', 'Hot Tamales', 'Mike &amp; Ikes', 'Pez'] },</span>
<span style="color: #339933;">            { header:'Cookies', items:['Chewy Chips Ahoy', 'Mint Milano', 'Oreo', 'Nutter Butter', 'Fig Newtons'] }];</span>
<span style="color: #339933;">    ]]&gt;</span>
<span style="color: #339933;">    &lt;/mx:Script&gt;</span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Style</span> source=<span style="color: #ff0000;">&quot;style.css&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:VBox</span> width=<span style="color: #ff0000;">&quot;140&quot;</span> styleName=<span style="color: #ff0000;">&quot;container&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Repeater</span> id=<span style="color: #ff0000;">&quot;r&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{goodies}&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;flexlibContainer:WindowShade</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> styleName=<span style="color: #ff0000;">&quot;shade&quot;</span></span>
<span style="color: #000000;">                    data=<span style="color: #ff0000;">&quot;{r.currentItem.header}&quot;</span></span>
<span style="color: #000000;">                    opened=<span style="color: #ff0000;">&quot;{r.currentIndex == 0}&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;flexlibContainer:headerRenderer</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Component</span><span style="color: #7400FF;">&gt;</span></span>
                        <span style="color: #000000;"><span style="color: #7400FF;">&lt;flexlibControl:CanvasButton</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> height=<span style="color: #ff0000;">&quot;30&quot;</span> styleName=<span style="color: #ff0000;">&quot;shadeBtn&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                            <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">                            &lt;![CDATA[</span>
<span style="color: #339933;">                                import flexlib.containers.WindowShade;</span>
<span style="color: #339933;">                            ]]&gt;</span>
<span style="color: #339933;">                            &lt;/mx:Script&gt;</span>
&nbsp;
                            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Label</span> id=<span style="color: #ff0000;">&quot;header&quot;</span> top=<span style="color: #ff0000;">&quot;3&quot;</span> left=<span style="color: #ff0000;">&quot;4&quot;</span> text=<span style="color: #ff0000;">&quot;{WindowShade(parent).data}&quot;</span> styleName=<span style="color: #ff0000;">&quot;shadeHead&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
                            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:CheckBox</span> id=<span style="color: #ff0000;">&quot;chk&quot;</span> top=<span style="color: #ff0000;">&quot;9&quot;</span> right=<span style="color: #ff0000;">&quot;6&quot;</span> selected=<span style="color: #ff0000;">&quot;{WindowShade(parent).opened}&quot;</span> styleName=<span style="color: #ff0000;">&quot;shadeChk&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/flexlibControl:CanvasButton</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Component</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;/flexlibContainer:headerRenderer</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:List</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{r.currentItem.items}&quot;</span> rowCount=<span style="color: #ff0000;">&quot;{r.currentItem.items.length}&quot;</span> styleName=<span style="color: #ff0000;">&quot;shadeList&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/flexlibContainer:WindowShade</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Repeater</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:VBox</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>After throwing in some colors from a sweet <a href="http://kuler.adobe.com/#themeID/356863">Kuler theme</a> and embedding Helvetica, we get this:</p>
<p><a href="http://saturnboy.com/proj/shade/shade2/shade2.html">shade 2</a> (view source enabled)</p>
<p>At this point, I was really happy with look and feel, but there we still a few minor issues with the CanvasButton header that needed to be fixed before declaring victory.</p>
<h5>Fixups</h5>
<p>First, I needed the rollover event to flow down to the checkbox, so it would correctly show the overSkin on mouse over.  Second, I wanted a color change on the Label on rollover to provide better visual feedback to the user.  And lastly, I wanted the entire CanvasButton header to be clickable, not just the label text or the checkbox graphic.</p>
<p class="bottom">Focusing just on the modified CanvasButton code, used in the <code>headerRendered</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;flexlibControl:CanvasButton</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> height=<span style="color: #ff0000;">&quot;30&quot;</span> styleName=<span style="color: #ff0000;">&quot;shadeBtn&quot;</span></span>
<span style="color: #000000;">        rollOver=<span style="color: #ff0000;">&quot;header.setStyle('color', 0xffffff); chk.dispatchEvent(event);&quot;</span></span>
<span style="color: #000000;">        rollOut=<span style="color: #ff0000;">&quot;header.setStyle('color', 0xcccccc); chk.dispatchEvent(event);&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">    &lt;![CDATA[</span>
<span style="color: #339933;">        import flexlib.containers.WindowShade;</span>
<span style="color: #339933;">    ]]&gt;</span>
<span style="color: #339933;">    &lt;/mx:Script&gt;</span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Label</span> id=<span style="color: #ff0000;">&quot;header&quot;</span> top=<span style="color: #ff0000;">&quot;3&quot;</span> left=<span style="color: #ff0000;">&quot;4&quot;</span> text=<span style="color: #ff0000;">&quot;{WindowShade(parent).data}&quot;</span> styleName=<span style="color: #ff0000;">&quot;shadeHead&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:CheckBox</span> id=<span style="color: #ff0000;">&quot;chk&quot;</span> top=<span style="color: #ff0000;">&quot;9&quot;</span> right=<span style="color: #ff0000;">&quot;6&quot;</span> selected=<span style="color: #ff0000;">&quot;{WindowShade(parent).opened}&quot;</span> styleName=<span style="color: #ff0000;">&quot;shadeChk&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Canvas</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> height=<span style="color: #ff0000;">&quot;100%&quot;</span> backgroundColor=<span style="color: #ff0000;">&quot;#000000&quot;</span> backgroundAlpha=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/flexlibControl:CanvasButton</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>The final result, a nice styled WindowShade:</p>
<p><a href="http://saturnboy.com/proj/shade/shade3/shade3.html">shade 3</a> (view source enabled)</p>
<p>I used the parent CanvasButton&#8217;s rollover event to set the child Label color and forward the event to the child CheckBox.  To make the entire button clickable, I used one of my favorite Flex UI hacks: I added a space-filling transparent Canvas.</p>
<h5>Comparison Shopping</h5>
<p class="bottom">And finally, a side-by-side comparison of all three WindowShade skins:</p>
<div id="flashcontent-windowshade">
Flash is required.  <a href="http://www.adobe.com/go/getflashplayer">Get it here!</a>
</div>
<p><b>Update:</b> See my <a href="http://saturnboy.com/2010/06/drawer-component-flex-4/">Drawer Component in Flex 4</a> post for a custom collapsible drawer component written from scratch in Flex 4.</p>
<div>
<script type="text/javascript">
swfobject.embedSWF('http://saturnboy.com/proj/shade/shade/shade.swf', 'flashcontent-windowshade', '530', '400', '9.0.28', 'expressInstall.swf', false, { bgColor:'#ffffff', base:'.' });
</script>
</div>
]]></content:encoded>
			<wfw:commentRss>http://saturnboy.com/2009/03/styling-flexlib-windowshade/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Designing in Flex</title>
		<link>http://saturnboy.com/2009/02/designing-in-flex/</link>
		<comments>http://saturnboy.com/2009/02/designing-in-flex/#comments</comments>
		<pubDate>Sun, 08 Feb 2009 06:04:02 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://saturnboy.com/?p=188</guid>
		<description><![CDATA[Flex is awesome. In many ways, it&#8217;s the right tool for the job of bringing beautiful design to the web. I use flex every day at work, and also at home on my own fun projects. Today&#8217;s challenge is to take a very simple blog design and re-implement it in flex. In The Red Corner [...]]]></description>
			<content:encoded><![CDATA[<p>Flex is awesome.  In many ways, it&#8217;s the right tool for the job of bringing beautiful design to the web.  I use flex every day <a href="http://www.gorillalogic.com/">at work</a>, and also at home on my own <a href="http://saturnboy.com/projects/">fun projects</a>.  Today&#8217;s challenge is to take a very simple blog design and re-implement it in flex.</p>
<h5>In The Red Corner</h5>
<p>I&#8217;ll start with my simple two-column blog design that I like to call <b>Circles of Doom</b>.  The original design was done in <a href="http://www.inkscape.org/">Inkscape</a>, and assembled for the web using <a href="http://www.blueprintcss.org/">Blueprint CSS</a>.  You can read all the gory details of the design and assembly in a series of earlier posts: <a href="http://saturnboy.com/2008/11/blueprint-css-magic/">part 1</a>, <a href="http://saturnboy.com/2008/11/designing-with-inkscape-and-blueprint-css/">part 2</a>, <a href="http://saturnboy.com/2008/12/slice-and-dice/">part 3</a>, <a href="http://saturnboy.com/2009/02/optimizing-web-design/">part 4</a>.</p>
<p>Skipping right to the end result, you can view the final results here:</p>
<div class="span-11 prepend-3">
<div class="span-4" style="text-align:center; border: 4px solid #999; background-color: #eef;">
<h3 class="top bottom" style="padding:10px 0;"><a href="http://saturnboy.com/proj/circles_of_doom/v2/" target="_blank">html + css</a></h3>
</div>
<div class="span-4 last" style="text-align:center; border: 4px solid #999; background-color: #fee;">
<h3 class="top bottom" style="padding:10px 0;"><a href="http://saturnboy.com/proj/circles_of_doom/flex/" target="_blank">flex</a></h3>
</div>
</div>
<p class="top bottom">&nbsp;</p>
<h5>In The Blue Corner</h5>
<p>Flex provides a lot of design leverage with its support for fills &#038; strokes, gradients, rounded corners, and filters like drop shadow and glow.  The original html design required the use of images to handle these features, but Flex&#8217;s CSS is powerful enough to handle everything with the exception of the <a href="http://saturnboy.com/proj/circles_of_doom/flex/srcview/source/assets/circ.png">blood red background circles</a>.</p>
<p>The design architecture can be thought of as a simple three layer structure show here:</p>
<div class="span-14 top bottom" style="min-height:254px; text-align:center;">
<img src="http://saturnboy.com/wp-content/uploads/2009/02/flex-layers-diagram.png" alt="flex layers diagram" title="flex layers diagram" width="521" height="244" />
</div>
<p>The bottom layer has the blood red background circle image.  It is absolutely positioned vertically (<code>y="-65"</code>) and horizontally centered (<code>x="{(this.width - 950)/2}"</code>).  Like this:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Image</span> source=<span style="color: #ff0000;">&quot;@Embed(source='assets/circ.png')&quot;</span></span>
<span style="color: #000000;">        x=<span style="color: #ff0000;">&quot;{(this.width - 950)/2}&quot;</span> y=<span style="color: #ff0000;">&quot;-65&quot;</span> <span style="color: #7400FF;">/&gt;</span></span></pre></div></div>

<p>The middle layer has the main box with rounded corners and a black glow.  Like this:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:VBox</span> width=<span style="color: #ff0000;">&quot;870&quot;</span> x=<span style="color: #ff0000;">&quot;{(this.width - 870)/2}&quot;</span> y=<span style="color: #ff0000;">&quot;130&quot;</span> styleName=<span style="color: #ff0000;">&quot;body&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:filters</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:GlowFilter</span> blurX=<span style="color: #ff0000;">&quot;22&quot;</span> blurY=<span style="color: #ff0000;">&quot;22&quot;</span> color=<span style="color: #ff0000;">&quot;#111111&quot;</span> alpha=<span style="color: #ff0000;">&quot;0.6&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:filters</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:VBox</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>And the Flex CSS:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">VBox<span style="color: #6666ff;">.body</span> <span style="color: #00AA00;">&#123;</span>
	horizontalAlign<span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
	backgroundColor<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ffffff</span><span style="color: #00AA00;">;</span>
	borderStyle<span style="color: #00AA00;">:</span> <span style="color: #993333;">solid</span><span style="color: #00AA00;">;</span>
	borderThickness<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">10</span><span style="color: #00AA00;">;</span>
	borderColor<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#886655</span><span style="color: #00AA00;">;</span>
	cornerRadius<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">28</span><span style="color: #00AA00;">;</span>
	verticalGap<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">10</span><span style="color: #00AA00;">;</span>
	paddingTop<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">20</span><span style="color: #00AA00;">;</span> paddingBottom<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">4</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>And the top layer has the main content, sidebar &#038; sidebar content, and footer. Like this:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Canvas</span> width=<span style="color: #ff0000;">&quot;790&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Text</span> text=<span style="color: #ff0000;">&quot;main&quot;</span> width=<span style="color: #ff0000;">&quot;590&quot;</span> styleName=<span style="color: #ff0000;">&quot;contentTxt&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:VBox</span> width=<span style="color: #ff0000;">&quot;190&quot;</span> x=<span style="color: #ff0000;">&quot;600&quot;</span> styleName=<span style="color: #ff0000;">&quot;sidebar&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Text</span> text=<span style="color: #ff0000;">&quot;sidebar&quot;</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> styleName=<span style="color: #ff0000;">&quot;sidebarTxt&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:VBox</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Canvas</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Text</span> textg=<span style="color: #ff0000;">&quot;footer&quot;</span> styleName=<span style="color: #ff0000;">&quot;footerTxt&quot;</span> <span style="color: #7400FF;">/&gt;</span></span></pre></div></div>

<p>And the associated Flex CSS:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">Text<span style="color: #6666ff;">.contentTxt</span> <span style="color: #00AA00;">&#123;</span>
	fontFamily<span style="color: #00AA00;">:</span> Arial<span style="color: #00AA00;">;</span>
	fontSize<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">12</span><span style="color: #00AA00;">;</span>
	fontWeight<span style="color: #00AA00;">:</span> <span style="color: #993333;">normal</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000000</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
VBox<span style="color: #6666ff;">.sidebar</span> <span style="color: #00AA00;">&#123;</span>
	backgroundColor<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#aa1100</span><span style="color: #00AA00;">;</span>
	borderStyle<span style="color: #00AA00;">:</span> <span style="color: #993333;">solid</span><span style="color: #00AA00;">;</span>
	borderThickness<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">2</span><span style="color: #00AA00;">;</span>
	borderColor<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ff2200</span><span style="color: #00AA00;">;</span>
	cornerRadius<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">12</span><span style="color: #00AA00;">;</span>
	paddingLeft<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">10</span><span style="color: #00AA00;">;</span> paddingRight<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">10</span><span style="color: #00AA00;">;</span>
	paddingTop<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">10</span><span style="color: #00AA00;">;</span> paddingBottom<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">10</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
Text<span style="color: #6666ff;">.sidebarTxt</span> <span style="color: #00AA00;">&#123;</span>
	fontFamily<span style="color: #00AA00;">:</span> Arial<span style="color: #00AA00;">;</span>
	fontSize<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">12</span><span style="color: #00AA00;">;</span>
	fontWeight<span style="color: #00AA00;">:</span> <span style="color: #993333;">normal</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ffffff</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
Text<span style="color: #6666ff;">.footerTxt</span> <span style="color: #00AA00;">&#123;</span>
	fontFamily<span style="color: #00AA00;">:</span> Arial<span style="color: #00AA00;">;</span>
	fontSize<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">10</span><span style="color: #00AA00;">;</span>
	fontWeight<span style="color: #00AA00;">:</span> <span style="color: #993333;">normal</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#886655</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h5>The Result</h5>
<p>Put it all together with some dummy <a href="http://en.wikipedia.org/wiki/Lorem_ipsum">Lorem ipsum</a> text and you get a decent looking <a href="http://saturnboy.com/proj/circles_of_doom/flex/" target="_blank">Flex blog design</a> (just right-click, and select &#8220;view source&#8221; to see the code).  It compares favorably to the <a href="http://saturnboy.com/proj/circles_of_doom/v2/" target="_blank">original html design</a>.  The only obvious difference is the browser font rendering versus Flex&#8217;s font rendering.</p>
<h5>The Files</h5>
<ul>
<li><a href="http://saturnboy.com/proj/circles_of_doom/flex/circles_of_doom_flex.tgz">circles_of_doom_flex.tgz</a> (<a href="http://saturnboy.com/proj/circles_of_doom/flex/">view</a>)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://saturnboy.com/2009/02/designing-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimizing Web Design</title>
		<link>http://saturnboy.com/2009/02/optimizing-web-design/</link>
		<comments>http://saturnboy.com/2009/02/optimizing-web-design/#comments</comments>
		<pubDate>Sun, 01 Feb 2009 19:49:24 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[blueprint css]]></category>
		<category><![CDATA[design]]></category>

		<guid isPermaLink="false">http://saturnboy.com/?p=132</guid>
		<description><![CDATA[Once everything is done (meaning I have a layout, I have a design, and I have it sliced and assembled), I like to make another pass to optimize both the size of the image files, and the number of files. My two favorite techniques are using Sprites to reduce the total number of images, and [...]]]></description>
			<content:encoded><![CDATA[<p>Once everything is done (meaning I have a <a href="http://saturnboy.com/2008/11/blueprint-css-magic/">layout</a>, I have a <a href="http://saturnboy.com/2008/11/designing-with-inkscape-and-blueprint-css/">design</a>, and I have it <a href="http://saturnboy.com/2008/12/slice-and-dice/">sliced and assembled</a>), I like to make another pass to optimize both the size of the image files, and the number of files.  My two favorite techniques are using <a href="http://www.alistapart.com/articles/sprites/">Sprites</a> to reduce the total number of images, and using <a href="http://optipng.sourceforge.net/">OptiPNG</a> to compress the images.</p>
<h5>Sprites</h5>
<p>It is fairly common to see sprites used in high performance web design.  The Gmail team has a great <a href="http://gmailblog.blogspot.com/2008/05/need-for-speed-path-to-faster-loading.html">blog post</a> discussing various performance enhancements currently in use, including sprites.  But for some reason, almost everyone thinks of sprites for icons and buttons.  In my opinion, any time you can fuse two images into one, you&#8217;re making a &#8220;sprite&#8221; and you&#8217;re improving performance.  Using a grid-based framework like <a href="http://blueprintcss.org/">Blueprint CSS</a> tends create a lot of rectangular layout imagery, which are often ideally suited for fusing into a larger sprite.</p>
<p>The current <a href="http://saturnboy.com/2008/12/slice-and-dice/">web page</a> has two candidates for spriting: the main header image can be fused to the footer, and the sidebar header to the sidebar footer.  Just like this:</p>
<div class="span-14 top bottom" style="min-height:108px; text-align:center;">
<img src="http://saturnboy.com/wp-content/uploads/2009/01/fuse-diagram.png" alt="fuse diagram" title="fuse diagram" width="340" height="98" />
</div>
<p>So the original <a href="http://saturnboy.com/proj/circles_of_doom/v1/img/circ-head.png"><code>circ-head.png</code></a> and <a href="http://saturnboy.com/proj/circles_of_doom/v1/img/circ-foot.png"><code>circ-foot.png</code></a> are fused to create <a href="http://saturnboy.com/proj/circles_of_doom/v2/img/circ.png"><code>circ.png</code></a>.  Similarly, the sidebar header and footer are fused to create <a href="http://saturnboy.com/proj/circles_of_doom/v2/img/sidebar.png"><code>sidebar.png</code></a>.</p>
<p>The original <a href="http://saturnboy.com/proj/circles_of_doom/v1/circ.css"><code>circ.css</code></a> is simply modified with the new image filenames and a negative vertical offsets on the footer backgrounds.  Here are the relevant parts of the new <a href="http://saturnboy.com/proj/circles_of_doom/v2/circ.css"><code>circ.css</code></a>:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#header</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#111</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">img/circ.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">160px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">160px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#footer</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#111</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">img/circ.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-160px</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#sidehead</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #3333ff;">:<span style="color: #993333;">transparent</span> </span>url<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">img/sidebar.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#sidefoot</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #3333ff;">:<span style="color: #993333;">transparent</span> </span>url<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">img/sidebar.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-14px</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h5>Compression</h5>
<p>Using OptiPNG is really easy.  Just run it over a folder of PNGs, and it losslessly compresses what it can, and leaves the rest untouched.  When I&#8217;m not using source control on a design, I&#8217;ll often perform the compression step exclusively on the server to keep things simple.</p>
<p>Here is a simple command to perform maximum compression of all the PNGs in a folder:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">optipng <span style="color: #660033;">-o7</span> <span style="color: #000000; font-weight: bold;">*</span>.png</pre></div></div>

<blockquote class="deeper"><p><b>Digging Deeper:</b> I have noticed that OptiPNG, in it&#8217;s quest for maximum optimization, will sometimes alter the image type (either by reducing the bit depth or switching from full color to indexed color) in such a way as to make Photoshop very unhappy with the resulting image.  In these cases, the <a href="http://gimp.org/">GIMP</a> is your friend.</p></blockquote>
<h5>The Results</h5>
<p>We fused four images totaling 52552 bytes into two images totaling 52356 bytes.  So we saved two whole HTTP requests and a meager 200 bytes.  Not much to write home about (or even blog about), but hopefully it serves as a useful demonstration that design optimization is fairly simple.  Next up, we&#8217;ll take our <a href="http://saturnboy.com/2009/02/designing-in-flexdesigning-in-flex/">design and layout into Flex</a>.  What fun!</p>
<h5>The Files</h5>
<ul>
<li><a href="http://saturnboy.com/proj/circles_of_doom/circles_of_doom_v2.tgz">circles_of_doom_v2.tgz</a> (<a href="http://saturnboy.com/proj/circles_of_doom/v2/">view</a>)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://saturnboy.com/2009/02/optimizing-web-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Slice and Dice</title>
		<link>http://saturnboy.com/2008/12/slice-and-dice/</link>
		<comments>http://saturnboy.com/2008/12/slice-and-dice/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 05:19:17 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[blueprint css]]></category>
		<category><![CDATA[design]]></category>

		<guid isPermaLink="false">http://saturnboy.com/?p=101</guid>
		<description><![CDATA[The design from the last post is finished, and it follows a very simple blog layout. In this post, I&#8217;ll slice the design and turn it into a pretty html page with the magic of Blueprint CSS. Slice It Before we get slice happy, we need to think. First, Blueprint is grid-based, so that means [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://saturnboy.com/wp-content/uploads/2008/11/circles-of-doom.png">design</a> from the <a href="http://saturnboy.com/2008/11/designing-with-inkscape-and-blueprint-css/">last post</a> is finished, and it follows a very <a href="http://saturnboy.com/2008/11/blueprint-css-magic/">simple blog layout</a>.  In this post, I&#8217;ll slice the design and turn it into a pretty html page with the magic of <a href="http://www.blueprintcss.org/">Blueprint CSS</a>.</p>
<h5>Slice It</h5>
<p>Before we get slice happy, we need to think.  First, Blueprint is grid-based, so that means rectangles are good.  And second, the default Blueprint container width is 950px.  The defaults are intelligently chosen and have always worked great for me.  By sticking with the defaults, we will get a 950px wide, centered, fixed-width site, which is exactly what we want.</p>
<p class="bottom">We could get all clever and try to slice out just the circles as a background image, but that would force the top border to be a transparent PNG because of the shadow.  Similarly, we could cut out all four rounded corners and all four edges of the sidebar, but that would force us to reassemble humpty dumpty with some fancy css and markup.  In both cases, just say No!  The simplest possible choice is to slice the entire header, the entire footer, and then a thin slice for the body that can be vertically tiled.  Exactly like this:</p>
<div class="span-14 top bottom" style="min-height:310px; text-align:center;">
<img src="http://saturnboy.com/wp-content/uploads/2008/11/slice_diagram.png" alt="slice diagram" title="slice diagram" width="360" height="300" />
</div>
<p>And we get: <a href="http://saturnboy.com/wp-content/uploads/2008/12/circ-head.png">the header</a>, <a href="http://saturnboy.com/wp-content/uploads/2008/12/circ-bg.png">the background tile</a>, and <a href="http://saturnboy.com/wp-content/uploads/2008/12/circ-foot.png">the footer</a>.  Slicing the sidebar in the exact same manner gives: <a href="http://saturnboy.com/wp-content/uploads/2008/12/sidebar-head.png">sidebar header</a>, <a href="http://saturnboy.com/wp-content/uploads/2008/12/sidebar-bg.png">sidebar background tile</a>, and <a href="http://saturnboy.com/wp-content/uploads/2008/12/sidebar-foot.png">sidebar footer</a>.</p>
<h5>Code It</h5>
<p class="bottom">The original <a href="http://saturnboy.com/2008/11/blueprint-css-magic/">simple blog layout</a> had four divs: header, content, sidebar, and footer.  This is exactly want we want, but the original markup won&#8217;t exactly work, because the current design has a vertically-tiled background.  The solution is simple &ndash; just wrap the content and sidebar inside a div with a bit of padding (via a <code>prepend-2</code> and <code>append-2</code>).  If we ignore the sidebar design for a moment, and just insert a placeholder, the markup is:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;container&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;header&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;span-24&quot;</span>&gt;</span>header<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;bg&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;prepend-2 span-20 append-2&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;content&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;span-15&quot;</span>&gt;</span>content<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sidebar&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;span-5 last&quot;</span>&gt;</span>sidebar<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;footer&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;span-24&quot;</span>&gt;</span>footer<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<p class="bottom">That&#8217;s just beautiful Blueprint markup!  Adding some simple css:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#111</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#header</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#111</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">img/circ-head.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">160px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">160px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#footer</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#111</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">img/circ-foot.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#bg</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">img/circ-bg.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333;">repeat-y</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>And that gives us Circles of Doom, version 0!  <a href="http://saturnboy.com/proj/circles_of_doom/v0/">View it</a>, or <a href="http://saturnboy.com/proj/circles_of_doom/circles_of_doom_v0.tgz">download it</a>.  I&#8217;ve included the latest-and-greatest <a href="http://www.blueprintcss.org/">Blueprint CSS</a>, which is <a href="http://www.christianmontoya.com/2008/11/11/blueprint-version-08/">v0.8</a> at the time of writing.  I&#8217;ve chosen to enforce the vertical height of the header and footer via <code>height</code> and <code>min-height</code> which seems to work fine in Firefox, Safari, and IE7.</p>
<h5>Sidebar Me</h5>
<p class="bottom">Since the sidebar graphic was sliced in the exact same manner as the body graphic, we just add the exact same markup to the sidebar div &ndash; header, bg, and footer.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sidebar&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;span-5 last&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sidehead&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;span-5&quot;</span>&gt;</span><span style="color: #808080; font-style: italic;">&lt;!-- sidebar header --&gt;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sidebg&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;span-5&quot;</span>&gt;</span>sidebar content<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sidefoot&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;span-5&quot;</span>&gt;</span><span style="color: #808080; font-style: italic;">&lt;!-- sidebar footer --&gt;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<p class="bottom">Style it like this:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#sidehead</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #3333ff;">:<span style="color: #993333;">transparent</span> </span>url<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">img/sidebar-head.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#sidefoot</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #3333ff;">:<span style="color: #993333;">transparent</span> </span>url<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">img/sidebar-foot.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#sidebg</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #3333ff;">:<span style="color: #993333;">transparent</span> </span>url<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">img/sidebar-bg.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333;">repeat-y</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Putting everything together with some dummy <a href="http://en.wikipedia.org/wiki/Lorem_ipsum">Lorem Ipsum</a> text gives us Circles of Doom, version 1!  <a href="http://saturnboy.com/proj/circles_of_doom/v1/">View it</a>, or <a href="http://saturnboy.com/proj/circles_of_doom/circles_of_doom_v1.tgz">download it</a>.</p>
<h5>Debug It</h5>
<p class="bottom">Lorem Ipsum text is the basic unit testing for HTML+CSS.  I always fill out every content div with some dummy text, just to see what breaks.  This time around, I noticed the sidebar content was touching the edges.   I decided against adding a <code>prepend-1</code> and <code>append-1</code> because that&#8217;s too much padding.  Instead, I thought I might just add some padding to <code>sidebg</code>, but this is bad, bad, bad!  <strong>You can not add padding or margins to a Blueprint node</strong>, which <code>sidebg</code> clearly is because of the <code>class="span-5"</code>.  I could add another div inside <code>sidebg</code>, but that seemed like too much markup.  So, I took the easy way out and just padded the known sidebar content markup (in this case, just <code>p</code> and <code>h3</code>).</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#sidebar</span> h3<span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#sidebar</span> p <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<blockquote class="deeper"><p><b>Digging Deeper:</b> Blueprint CSS uses <code>margin</code> and <code>padding</code> to create the grid.  Thus it should have been obvious to me that you can NOT add margins or padding to a Blueprint element (any markup element with a Blueprint grid class).  Alas, it was not immediately obvious, but I was able to catch my mistake during debugging.</p></blockquote>
<p>And that&#8217;s it for the visual aspect of Circles of Doom.  Next, I&#8217;ll cover <a href="http://saturnboy.com/2009/02/optimizing-web-design/">web design optimization</a>.</p>
<h5>The Files</h5>
<ul>
<li><a href="http://saturnboy.com/proj/circles_of_doom/circles_of_doom_v0.tgz">circles_of_doom_v0.tgz</a> (<a href="http://saturnboy.com/proj/circles_of_doom/v0/">view</a>)</li>
<li><a href="http://saturnboy.com/proj/circles_of_doom/circles_of_doom_v1.tgz">circles_of_doom_v1.tgz</a> (<a href="http://saturnboy.com/proj/circles_of_doom/v1/">view</a>)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://saturnboy.com/2008/12/slice-and-dice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Designing with Inkscape and Blueprint CSS</title>
		<link>http://saturnboy.com/2008/11/designing-with-inkscape-and-blueprint-css/</link>
		<comments>http://saturnboy.com/2008/11/designing-with-inkscape-and-blueprint-css/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 05:15:42 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[blueprint css]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[inkscape]]></category>

		<guid isPermaLink="false">http://saturnboy.com/?p=69</guid>
		<description><![CDATA[I don&#8217;t know how a real designer does it, but when I attempt a design, particularly a blog design, I always start with a simple theme. If the ideas begin to flow, I&#8217;ll know I chose well. If not, and I still think it&#8217;s a good theme, I&#8217;ll visit the usual suspects for some inspiration. [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t know how a real designer does it, but when I attempt a design, particularly a blog design, I always start with a simple theme.  If the ideas begin to flow, I&#8217;ll know I chose well.  If not, and I still think it&#8217;s a good theme, I&#8217;ll visit the <a href="http://www.deviantart.com/">usual</a> <a href="http://images.google.com/">suspects</a> for some inspiration.</p>
<p>On this blog, I started with robots, which quickly lead to gears and mechanics.  For this post, I started with circles.  Actually, I started with Ironman&#8217;s HUD.  The whole movie was super cool, but the HUD was the best.  And the HUD had all this motion and targeting, and that&#8217;s what got me to circles.  So that&#8217;s the theme.  I already know I&#8217;m going to apply this theme to a simple grid-based blog layer that I <a href="http://saturnboy.com/2008/11/blueprint-css-magic/">discussed earlier</a>.</p>
<h5>Palette</h5>
<p class="bottom">After the theme, I worked on the color palette.  I&#8217;ve used <a href="http://kuler.adobe.com/">Kuler</a> in the past to build out a couple of palettes, but this time I just jumped into <a href="http://inkscape.org/">Inkscape</a> and started messing around.  I came up with a nice blood red and black palette.</p>
<div class="span-14 top bottom" style="min-height:58px; text-align:center;">
<img src="http://saturnboy.com/wp-content/uploads/2008/11/palette.png" alt="palette" title="palette" width="250" height="48" />
</div>
<h5>Circles</h5>
<p class="bottom">Now that I have a palette, I shift my design focus back to circles.  It&#8217;s not just gonna be &#8220;Dot, dot, dot&#8221; as my daughter likes to say, so it&#8217;s back to Inkscape.  Here&#8217;s the result:</p>
<div class="span-14 top bottom" style="min-height:148px; text-align:center;">
<img src="http://saturnboy.com/wp-content/uploads/2008/11/circles.png" alt="circles" title="circles" width="325" height="138" />
</div>
<h5>Layout</h5>
<p>Not much left but the real work &ndash; make a cool blog design with circles plus some pretty colors.  I know my <a href="http://saturnboy.com/2008/11/blueprint-css-magic/">layout</a>, so once again it&#8217;s back to Inkscape.  There is a nice <a href="http://www.vunzzz.net/blueprint-inkscape/">Inkscape template generator</a> for Blueprint CSS grid layouts.  Choosing which colors go where isn&#8217;t too bad, because I love dark text on white for blogs.  Following that decision, I go with lots of circles in the header in blood red, over a black background.  We know the main content will be white with black text, so I decide to make the sidebar really stand out with a bold blood red.</p>
<p class="bottom">The circles in the header are really easy, I just pick random sizes and put them in random locations.  Darker usually means further away, so I just reduce the opacity to let more black through.  I use a rounded rectangle with a thick stroke for the main content area.  I also add a black shadow around the entire content area to highlight the content.  The finished design is <a href="http://saturnboy.com/wp-content/uploads/2008/11/circles-of-doom.png" target="_blank">here</a>, and I&#8217;m calling it <strong>Circles Of Doom</strong>.  Here is a closeup of the header:</p>
<div class="span-14 top bottom" style="min-height:135px; text-align:center;">
<a href="http://saturnboy.com/wp-content/uploads/2008/11/circles-of-doom.png"><img src="http://saturnboy.com/wp-content/uploads/2008/11/circles-of-doom-closeup.png" alt="" title="circles-of-doom-closeup" width="300" height="125" /></a>
</div>
<p>Next, we <a href="http://saturnboy.com/2008/12/slice-and-dice/">slice and dice</a>&#8230;</p>
<h5>Files</h5>
<ul>
<li><a href="http://saturnboy.com/proj/circles_of_doom/palette.svg">palette.svg</a></li>
<li><a href="http://saturnboy.com/proj/circles_of_doom/circles.svg">circles.svg</a></li>
<li><a href="http://saturnboy.com/proj/circles_of_doom/circles-of-doom.svg">circles-of-doom.svg</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://saturnboy.com/2008/11/designing-with-inkscape-and-blueprint-css/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The Magic of Blueprint CSS</title>
		<link>http://saturnboy.com/2008/11/blueprint-css-magic/</link>
		<comments>http://saturnboy.com/2008/11/blueprint-css-magic/#comments</comments>
		<pubDate>Tue, 04 Nov 2008 05:50:06 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[blueprint css]]></category>
		<category><![CDATA[design]]></category>

		<guid isPermaLink="false">http://saturnboy.com/?p=43</guid>
		<description><![CDATA[I&#8217;m a bad designer. No amount of ego, or sugary coating can change that fact. Whenever I hang out with my coding buddies to talk design, they actually think I might border on decent. It&#8217;s either midget aliens piloting their husks or their brains have been pickled from over-exposure to Hibernate mapping files. Thankfully, I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a bad designer.  No amount of ego, or sugary coating can change that fact.  Whenever I hang out with my coding buddies to talk design, they actually think I might border on decent.  It&#8217;s either midget aliens piloting their husks or their brains have been pickled from over-exposure to Hibernate mapping files.  Thankfully, I&#8217;ve been around some real designers and they know the truth&#8230;if it&#8217;s brown and smelly it must be a turd.</p>
<p>I do, however, know what I like.  And when I&#8217;m build a blog, I like to have a header, footer, main content area, and a sidebar or two.  Since I need all the help I can get when it comes to website design, I always try to leverage what others have done.  In the case of this blog&#8217;s design, I&#8217;m using <a href="http://www.blueprintcss.org/">Blueprint CSS</a>, a bad ass grid-based CSS framework with smart typography defaults.</p>
<p>But before I dig into the details of my design, I want to start simple.  So imagine we want build a website with your basic two-column layout.</p>
<div class="span-14 top bottom" style="min-height:186px;text-align:center;">
<img src="http://saturnboy.com/wp-content/uploads/2008/11/blueprint-layout.png" alt="layout" title="layout" width="128" height="176" />
</div>
<p>Coding a basic layout like this one is almost too easy with Blueprint:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;container&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;header&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;span-24&quot;</span>&gt;</span>header<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;content&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;span-18&quot;</span>&gt;</span>content<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sidebar&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;span-6 last&quot;</span>&gt;</span>sidebar<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;footer&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;span-24&quot;</span>&gt;</span>footer<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<p>Add a pinch css to provide some color and some substance:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#header</span>  <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#cc6</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#footer</span>  <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#c6c</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#content</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#6c6</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">60px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#sidebar</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#6cc</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">60px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Now, put it all together, and you get this:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;</span>
<span style="color: #00bbdd;">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>Simple Blueprint Layout<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;blueprint/screen.css&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">media</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;screen, projection&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;blueprint/print.css&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">media</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;print&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>  
<span style="color: #808080; font-style: italic;">&lt;!--[if IE]&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;link rel=&quot;stylesheet&quot; href=&quot;blueprint/ie.css&quot; type=&quot;text/css&quot; media=&quot;screen, projection&quot; /&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;![endif]--&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">style</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span>&gt;</span>
#header  { background-color:#cc6; padding:30px 0; text-align:center; }
#footer  { background-color:#c6c; padding:30px 0; text-align:center; }
#content { background-color:#6c6; padding-bottom:60px; }
#sidebar { background-color:#6cc; padding-bottom:60px; }
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">style</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;container&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;header&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;span-24&quot;</span>&gt;</span>header<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;content&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;span-18&quot;</span>&gt;</span>content<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sidebar&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;span-6 last&quot;</span>&gt;</span>sidebar<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;footer&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;span-24&quot;</span>&gt;</span>footer<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p>Nothing much to see, all the grid and typography magic is hidden inside Blueprint CSS files.  It actually makes the final html code look lame.  <a href="http://saturnboy.com/wp-content/uploads/2008/11/simple-blueprint-layout.html">View the results</a>, and you can judge for yourself.  Next, I&#8217;ll <a href="http://saturnboy.com/2008/11/designing-with-inkscape-and-blueprint-css/">build an original design and continue digging into Blueprint</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://saturnboy.com/2008/11/blueprint-css-magic/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
