<?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>Journal - Mark Brown</title>
	<atom:link href="http://www.yellowshoe.com.au/journal/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.yellowshoe.com.au/journal</link>
	<description>HTML, CSS, Javascript</description>
	<lastBuildDate>Mon, 29 Apr 2013 09:25:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Balance</title>
		<link>http://www.yellowshoe.com.au/journal/balance/</link>
		<comments>http://www.yellowshoe.com.au/journal/balance/#comments</comments>
		<pubDate>Sun, 28 Apr 2013 04:59:28 +0000</pubDate>
		<dc:creator>Mark Brown</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.yellowshoe.com.au/journal/?p=290</guid>
		<description><![CDATA[Near the end of a four year stint in a corporate environment I took four weeks holiday by the beach. I relaxed, played guitar, prayed, treated acne, ate well and exercised with running, push ups and sit ups.  It was a great time of recovery and healing and I started feeling better about myself and more healthy in the process.]]></description>
			<content:encoded><![CDATA[<p>When I returned back to work one of my managers looked at me, surprised and laughing, saying &#8220;You look so healthy!.. I guess a holiday will do that&#8221;.  And I <em>was</em> healthier.  Up until that point my work and church had been my life, even church had become work where I served as a leader in youth group, worship team, and later the leadership team.  Study and music were my only escape from my work, I enjoyed the creative and intellectual stimulation that they brought and they made me feel.. more balanced.</p>
<ul>
<li>I joined Inspire9 in December, 2011 and my work life changed considerably.</li>
<li>I left my church of ten years and moved in with two high school mates and their partners near the city but far enough out of the smog for it to be enjoyable.</li>
<li>I was a beginner again.</li>
<li>I rested and played often by going to St Kilda beach or eating out with friends.</li>
<li>I bought a bicycle and began riding to work whenever the sun was out.</li>
</ul>
<p>It took me a little while to actually enjoy exercise other than riding but I got there in the end.  There&#8217;s a large group interested in fitness at inspire9 and they encouraged me to start running, now I love it.  Recently I was inspired by the gymnastics of Cirque du Soleil and <a href="http://www.youtube.com/watch?v=aLogFAbTlDI">Ido Portal&#8217;s thoughts on movement</a>.  I&#8217;m riding and running regularly and practicing my handstands most days, the stretches and strength exercises make me feel healthier, happier and more balanced.  I attended Yoga for the first time last week and instantly enjoyed it, even though I found it difficult.</p>
<p>Lastly but certainly not least there is a good woman in my life.  Trish is honest, kind and beautiful, we laugh often and comfort each another.  I like her a lot.</p>
<p>Right now, I feel I am living a more balanced and healthy life than I ever have:</p>
<ul>
<li>A balance in my physical body and spirituality.</li>
<li>A balance in intellectual study and artistic expression.</li>
<li>A balance in my relationships and my work.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.yellowshoe.com.au/journal/balance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vipassana</title>
		<link>http://www.yellowshoe.com.au/journal/vipassana/</link>
		<comments>http://www.yellowshoe.com.au/journal/vipassana/#comments</comments>
		<pubDate>Wed, 28 Nov 2012 13:28:01 +0000</pubDate>
		<dc:creator>Mark Brown</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.yellowshoe.com.au/journal/?p=280</guid>
		<description><![CDATA[Vipassana Meditation, The Art of Living<br />As taught by S.N.Goenka]]></description>
			<content:encoded><![CDATA[<p>A friendly nomadic German generously sent me a copy of this book in the mail, it&#8217;s a short 150 page book explaining the how&#8217;s and why&#8217;s of Vipassana meditation.</p>
<p>I have been wanting to learn more about meditation for a while now, ever since reading <a href="http://www.two-shay.com/articles/mindful-march">@xshay&#8217;s post</a> I suppose.  Ryan Singer&#8217;s <a href="http://www.offscreenmag.com/issue1/">OffscreenMag article</a> and Steve Jobs biography also encouraged me to look more closely at it.  These three gents are more intelligent, more skilled and more balanced than most.</p>
<p>My first surprise was finding that this form of Buddhist meditation wasn&#8217;t religious at all.  It asserts that suffering is caused by not understanding our own reactions &#8211; the reaction to pleasant sensations is craving, our reaction to unpleasant sensations is aversion.  The meditation itself focuses on breath and progresses to focusing on sensations in every part of the body, one at a time.</p>
<p>The aim of the meditation is to become aware of how our mind behaves, by trying to focus on one thing only(breath coming out of the nostrils) we become aware of all of the different sensations but we don&#8217;t react to them.<br />
As I understand it, the purpose of Vipassana is to simply observe ourselves to train our minds to focus, so that rather than reacting to our senses without understanding, we can simply recognize the sensation and choose how to respond.</p>
<p>It also includes some basic teaching on morality and encourages us to keep a pure mind:</p>
<ol>
<li>to abstain from killing any living creature
<li>to abstain from stealing
<li>to abstain from sexual misconduct
<li>to abstain from false speech
<li>to abstain from intoxicants
</ol>
<p>One part of the teaching that really resonated with me was teaching that we have only ourselves to blame for our unhappiness and suffering because it originates in our mind.  If we stop reacting to unpleasant sensations or wrongs that we feel have been made to us we can simply recognize them from a distance and move on.  No need to carry them with us and continue our suffering.</p>
<p>I&#8217;m willing to give the practical aspects of Vipassana a shot and see what I can learn about myself in the process of meditation, one of the real attractions to me is it&#8217;s simplicity.  I consider myself a happy person, but I would like to have greater control over how I react.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yellowshoe.com.au/journal/vipassana/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internet Explorer</title>
		<link>http://www.yellowshoe.com.au/journal/internet-explorer/</link>
		<comments>http://www.yellowshoe.com.au/journal/internet-explorer/#comments</comments>
		<pubDate>Sat, 10 Nov 2012 00:44:44 +0000</pubDate>
		<dc:creator>Mark Brown</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.yellowshoe.com.au/journal/?p=262</guid>
		<description><![CDATA[Building web sites is more enjoyable to me now thanks to team, tools, process and more capable browsers.  I really enjoy my work.]]></description>
			<content:encoded><![CDATA[<p>I have a confession to make, I don&#8217;t care much for Internet Explorer.<br />
I want my work to be as enjoyable as possible, I create better things that way and will live longer.</p>
<p>An enjoyable day of work is:</p>
<p>not having to wake up to an alarm<br />
espresso<br />
a casual ride along the Yarra<br />
friendly faces<br />
good music<br />
good food<br />
learning something new<br />
working with well designed things<br />
working with <a href="https://twitter.com/wernah">@wernah</a> designed things<br />
having machines work for you<br />
solving a problem<br />
deleting code<br />
not wasting time</p>
<p>This is what my average day looks like and it&#8217;s lovely.  I work on a macbook pro with Ruby, Rails, Sass &amp; Compass, CoffeeScript and excellent browsers i.e. Tools and frameworks that make me happy and keep me from repeating myself.  Programs and machines do the repetitive things far better than me so I let them and then thank them for their efforts, praising them to my fellow humans.</p>
<p>I&#8217;ve been consciously working on removing things from my workflow that aren&#8217;t pleasant or enjoyable.  I have no time for things that require too much effort to achieve too little.  I want to get as much done as a I can with as little effort, and I want to enjoy doing it too.<br />
I suppose this is why I never open up Windows, though I am interested in IE10 and Windows 8.</p>
<p>All of my development work is done in Firefox and Chrome.  When I release something, <em>most of the time</em> I will open up a VM with IE8 and 9 with the aim of making it work and then getting the hell out of there.<br />
zoom: 1, position: relative or float: left will fix things in IE.<br />
Learn about &#8220;hasLayout&#8221;, it will help you get out of there sooner.</p>
<p>If it&#8217;s CSS3 that&#8217;s difficult to provide a fallback for, take a deep breath and throw a <a href="http://css3pie.com/">PIE</a> at it. Seriously.<br />
With Sass and Compass you simply include it on the problematic elements and <a href="http://www.youtube.com/watch?v=r8L39UwOS-Y">Boom</a>, <a href="http://twitter.com/chriseppstein">Chris Eppstein</a>, <a href="http://twitter.com/lojjic">Jason Johnston</a>, thank you.</p>
<pre><code lang="css">.hawt-element {
  @include pie;
}</code></pre>
<p>I use shims and poly-fills cautiously but I have no problem throwing these types of scripted band-aids at Internet Explorer, it throws off the feng shui in my zen garden.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yellowshoe.com.au/journal/internet-explorer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Death</title>
		<link>http://www.yellowshoe.com.au/journal/death/</link>
		<comments>http://www.yellowshoe.com.au/journal/death/#comments</comments>
		<pubDate>Tue, 06 Nov 2012 03:57:39 +0000</pubDate>
		<dc:creator>Mark Brown</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.yellowshoe.com.au/journal/?p=237</guid>
		<description><![CDATA[This is proving difficult to write as I have no clear thoughts on what I truly believe or think about death, it's all a bit hazy.
Perhaps by the time I'm done writing this rambling piece I won't be pestered by it quite so often.]]></description>
			<content:encoded><![CDATA[<p>Without wanting to sound creepy, I think about death a lot.</p>
<p>For me, breaking the mould of routine has always triggered fresh thoughts on life and death.<br />
When I have moved on and not known where I&#8217;m headed I ask a lot of questions, these questions force me to make conscious decisions about my future.</p>
<p>Death motivates me to begin new things.<br />
This will sound exceptionally lame, but when Steve Jobs died I decided to quit my job of four years.  It is an uncomfortable reminder that our lives are indeed a vapour, we are here for only a moment and then we leave.</p>
<p>Death presents someone&#8217;s life to me as a short, singular entity with a sure end.<br />
I replay memories, perhaps writing some of the dearer ones down.<br />
If you forget interactions with someone who has passed away, those moments are lost forever.  Our lives are the cumulation of these sorts of simple interactions, we mustn&#8217;t forget them.</p>
<p>My favourite relative passed away last week.  Winnie wasn&#8217;t a direct relative, she was my mother&#8217;s father&#8217;s brother&#8217;s spouse.  I only remember meeting her a dozen times or so, but I loved her.  I loved her joyfulness and the excited way she reached out to greet me when I said hello at Christmases and birthday&#8217;s.  Her beaming smile and laugh was infectious, she expected nothing from me, she seemed perfectly happy simply to exchange smiles and share each others company.</p>
<p>Time had done it&#8217;s work and taken most of her eyesight and mobility, so she held my hands and found her way around my fingers like a blind person would to recognise and acknowledge another.<br />
I will miss her.</p>
<p>Death makes me sit up and take notice, of life&#8217;s simple interactions and also the bigger questions like our life&#8217;s work, legacy and meaning.</p>
<p>Ecclesiastes is an exploration of the meaning of life, the final chapter concludes with an exploration of aging and ultimately death.</p>
<p><q><span style="text-align:left"><br />
when the keepers of the house tremble,<br />
&nbsp;&nbsp;&nbsp;&nbsp;and the strong men stoop,<br />
when the grinders cease because they are few,<br />
&nbsp;&nbsp;&nbsp;&nbsp;and those looking through the windows grow dim;<br />
when the doors to the street are closed<br />
&nbsp;&nbsp;&nbsp;&nbsp;and the sound of grinding fades;<br />
when people rise up at the sound of birds,<br />
&nbsp;&nbsp;&nbsp;&nbsp;but all their songs grow faint;<br />
when people are afraid of heights<br />
&nbsp;&nbsp;&nbsp;&nbsp;and of dangers in the streets;<br />
when the almond tree blossoms<br />
&nbsp;&nbsp;&nbsp;&nbsp;and the grasshopper drags itself along<br />
&nbsp;&nbsp;&nbsp;&nbsp;and desire no longer is stirred.<br />
Then people go to their eternal home<br />
&nbsp;&nbsp;&nbsp;&nbsp;and mourners go about the streets.<br />
</span></q></p>
]]></content:encoded>
			<wfw:commentRss>http://www.yellowshoe.com.au/journal/death/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Front end chops</title>
		<link>http://www.yellowshoe.com.au/journal/front-end-chops/</link>
		<comments>http://www.yellowshoe.com.au/journal/front-end-chops/#comments</comments>
		<pubDate>Fri, 13 Jul 2012 12:25:43 +0000</pubDate>
		<dc:creator>Mark Brown</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.yellowshoe.com.au/journal/?p=208</guid>
		<description><![CDATA[The role of the front-end web developer has become more important, more complicated yet simpler in many ways.]]></description>
			<content:encoded><![CDATA[<p>This post is a response to <a href="https://twitter.com/rmurphey">@rmurphey&#8217;s</a> brilliant <a href="http://rmurphey.com/blog/2012/04/12/a-baseline-for-front-end-developers/">A Baseline for Front-End Developers</a> article.</p>
<p>It&#8217;s true that the role of the front-end developer has become both more important &amp; more complicated with the tooling and experience we are expected to have under our belts, but it&#8217;s become easier in a lot of respects.</p>
<h2>More important</h2>
<p>Javascript has grown up, left home, and is out taking on the world.  It is <a href="https://github.com/languages/">the most popular language on github</a> and is continually taking processing off the server and moving it to the client, this trend will continue.<br />
HTML5 has promoted web tech to another level of interactivity and power.<br />
CSS3 has enabled designers to implement effect and animations that previously required a lot of complex scripting or flash.<br />
Mobile devices have come out with great web browsers like Mobile Safari, Opera, Chrome and Firefox.<br />
Frameworks like PhoneGap have enabled web apps to power installed apps on all the major platforms.<br />
The web as a platform is kicking ass &#8211; an enthusistic crowd of designers/developers are building it daily, contributing to each others work. The web is deployable everywhere, future proof, cheap to build, and more powerful than ever.</p>
<h2>More complicated</h2>
<p>If you read Rebecca&#8217;s article you might feel overwhelmed at the level of things you need to learn, so lets simplify it &#8211; HTML, CSS &amp; Javascript is what&#8217;s important.  Know those and you can develop for the web.</p>
<p>Tools have complicated things though, there is now an ever present learning curve before us.  If you join a new team or project you will probably be expected to learn a handful of unfamiliar tools that the team has adopted, you&#8217;d also do well to be able to offer a handful of your own practices/tools/frameworks that you like.  Tooling is really highly valued at the moment.</p>
<p>I&#8217;m a keen learner but a late adopter, I don&#8217;t jump from one hot thing to the next.<br />
If you always adopt the hot new thing, you will often be adopting more code and complexity, the key is to find tools that require less code and complexity and allow you to do more.</p>
<p>The Javascript scene at the moment is very much the wild west.  It seems only yesterday that people actually cared what happened when javascript was disabled in the browser.  There is no one right way to build front-end web applications, my advice is to keep it as simple as possible and write as little code as you can get away with.</p>
<h2>Yet Simpler</h2>
<p>Browsers are great now, IE is dying.<br />
Web standards have won and it&#8217;s now easier to develop for the web.<br />
CSS3 means that there&#8217;s a lot of power and visual reward for a small amount of effort / code  #winning<br />
Libraries &#8211; while there&#8217;s more to learn, a lot of these libraries allow you to go further and do more.</p>
<p>SASS, Compass, jQuery, git, github, cucumber and Rails are my favorite tools &#8211; each save me a lot of time and allow me to write better, more elegant and maintainable code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yellowshoe.com.au/journal/front-end-chops/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Back to work</title>
		<link>http://www.yellowshoe.com.au/journal/back-to-work/</link>
		<comments>http://www.yellowshoe.com.au/journal/back-to-work/#comments</comments>
		<pubDate>Mon, 23 Apr 2012 10:42:35 +0000</pubDate>
		<dc:creator>Mark Brown</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.yellowshoe.com.au/journal/?p=210</guid>
		<description><![CDATA[I signed my life away to <a href="https://twitter.com/inspire9">@inspire9</a> today, I'm very happy to be working in such an amazing community and look forward to my work there.]]></description>
			<content:encoded><![CDATA[<div class="frame"><img src="/journal/wp-content/uploads/2012/04/i9.jpg"></div>
<h2>Leaving full-time employment</h2>
<p>Leaving my job was the best thing I have done for my career and personal development.<br />
Being unemployed without a plan is a very freeing and revealing thing, you are forced to ask those important questions like &#8220;What do I want to be doing with my short time left on the planet?&#8221; and &#8220;What do I want my work to accomplish?&#8221;.</p>
<p>I haven&#8217;t yet answered either of those, but having some free time on my hands I was able for the first time in a long while choose what I wanted to work on.  I set very simple, achievable goals for myself &#8211; I would linger around Inspire9, take on some freelance jobs to support myself and study.  For a year I would see if I could sustain myself and work on my craft, I also wanted to work along side talented people I could learn from.</p>
<h2>Client work</h2>
<p>I love working directly with clients, being able to contribute to a design, offer advice across wide areas(staffing, ux, design, development, workflows, timelines, marketing etc.).  I like the fact that small clients are small, they have more riding on their projects being successful and I like being able to contribute to that success.</p>
<p>I will continue to take on client work wherever I can.</p>
<h2>Extremely fortunate</h2>
<p>I feel extremely fortunate to be working on the web, in Melbourne.  There is a huge amount of good work available, I thought this would be the case but I was still surprised at the amount.  If you feel that you could be doing something more satisfying with your time, leave.</p>
<p>I only worked with four clients in my short time as a freelancer, two of those clients offered me ongoing work for the rest of the year that I&#8217;ve gladly accepted.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yellowshoe.com.au/journal/back-to-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Touch swipe events</title>
		<link>http://www.yellowshoe.com.au/journal/touch-swipe-events/</link>
		<comments>http://www.yellowshoe.com.au/journal/touch-swipe-events/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 07:54:36 +0000</pubDate>
		<dc:creator>Mark Brown</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.yellowshoe.com.au/journal/?p=182</guid>
		<description><![CDATA[I had to make an iOS like UI today and transition in different 'pages' by swiping.  A few gotcha's and how-to's if you're building something similar.]]></description>
			<content:encoded><![CDATA[<h2>HTML &#8211; Laying out the grid</h2>
<p>I first laid out a grid with a visible region the size of one of the pages.</p>
<div class="frame"><img src="/journal/wp-content/uploads/2012/03/grid.jpg"></div>
<pre><code lang="html">&lt;div id="grid-wrap"&gt;
  &lt;div id="grid"&gt;
    &lt;div id="pos-0-0"&gt;&lt;/div&gt;
    &lt;div id="pos-1-0"&gt;&lt;/div&gt;
    &lt;div id="pos-2-0"&gt;&lt;/div&gt;
    &lt;div id="pos-0-1"&gt;&lt;/div&gt;
    &lt;div id="pos-1-1"&gt;&lt;/div&gt;
    &lt;div id="pos-2-1"&gt;&lt;/div&gt;
    &lt;div id="pos-0-2"&gt;&lt;/div&gt;
    &lt;div id="pos-1-2"&gt;&lt;/div&gt;
    &lt;div id="pos-2-2"&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;</code></pre>
<h2>CSS</h2>
<p>All examples use SASS and Compass.</p>
<pre><code lang="css">$height: 748px;
$width: 1024px;
$rows = 3;
$cols = 3;

#grid-wrap {
  height: $height;
  width: $width;
  overflow: hidden;
}
#grid {
  height: $height * $rows;
  width: $width * $cols;
  @include transition(all .3s ease-in-out);
}
#grid > div {
  position: absolute;
  height: $height;
  width: $width;
  -webkit-backface-visibility: hidden;
}
@for $y from 0 through $rows-1 {
  @for $x from 0 through $cols-1 {
    .no-csstransforms {
      .pos-$x-$y {
        top: $y;
        left: $x;
      }
    }
    .csstransforms {
      .pos-$x-$y #grid {
        @include transform(translate($x*-$width, $y*-$height));
      }
    }
  }
}</code></pre>
<p>I first just transitioned the top and left values and it worked everywhere but the performance on the iPad wasn&#8217;t the best.  Webkit has heavily optimised transforms using translate so the result was much better using translate.  You could use modernizr to get the best of both worlds and serve transforms to the browsers that understand it. #winning.</p>
<p>-webkit-backface-visibility: hidden; is necessary so that the device renders the content off screen so that it doesn&#8217;t repaint when it&#8217;s scrolled in from one of the edges &#8211; without it the images flicker after a transition.</p>
<p>-webkit-backface-visibility did add a problem for me though, I was using a &lt;video&gt; element with video.js and I couldn&#8217;t click the play button within one of the elements with that property set. It took me a while to figure out but if you add a transform to the elements you need to interact with it somehow pulls them back into line.</p>
<pre><code lang="css">.video {
  @include transform(translate(0, 0));
}</code></pre>
<h2>Javascript</h2>
<p>I modified the <a href="http://www.netcu.de/jquery-touchwipe-iphone-ipad-library">jQuery Touchwipe Plugin</a> so that it normalised click and drag as well as touch events.  I also added a afterSwipe callback to make it a little more useful for me.</p>
<pre><code lang="javascript">$body = $('body');
var updatePos = function() {
  $body[0].className = 'pos-' + pos.x + '-' + pos.y;
}
$swiper = $body.swipe({
  swipeLeft: function() {
    if (pos.x < 2 &#038;&#038; pos.y !== 0)
    pos.x = pos.x+1;
  },
  swipeRight: function() {
    if (pos.x > 0 &#038;&#038; pos.y !== 0)
    pos.x = pos.x-1;
  },
  swipeUp: function() {
    if (pos.y < 2)
    pos.y = pos.y+1;
  },
  swipeDown: function() {
    if (pos.y > 0)
    pos.y = pos.y-1;
  },
  afterSwipe: updatePos,
  threshold: 20,
  preventDefaultEvents: true
});</code></pre>
<p>It&#8217;s fun playing with some of the -webkit features and seeing how they&#8217;ve optimised different features they deemed worthy enough for it.  The ease-in-out transitions with transforms feel just like the native experience &#8211; It&#8217;s worth going the extra steps to optimise for these devices.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yellowshoe.com.au/journal/touch-swipe-events/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SVG Motion Paths</title>
		<link>http://www.yellowshoe.com.au/journal/svg-motion-paths/</link>
		<comments>http://www.yellowshoe.com.au/journal/svg-motion-paths/#comments</comments>
		<pubDate>Thu, 15 Mar 2012 00:48:51 +0000</pubDate>
		<dc:creator>Mark Brown</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://www.yellowshoe.com.au/journal/?p=87</guid>
		<description><![CDATA[Building a simple HTML5 game this week I've learned heaps about motion graphics, Canvas and SVG.  I've also learnt a few new tricks with Sass and CSS transitions for keeping my code clean.]]></description>
			<content:encoded><![CDATA[<h2>Game On</h2>
<div class="frame" style="margin-bottom: 1em">
  <img src="/journal/wp-content/uploads/2012/03/board.jpg" alt="The game board" style="display: block">
</div>
<p>The <a href="http://www.twusuper.com.au/supergameoflife/">Super Game of Life</a> was beautifully designed by <a href="http://ie.com.au/">a Melbourne design agency</a>, it&#8217;s a simple turn based game with multiple choice answers.</p>
<p>You spin to move your car around the track, answering questions along the way, if you answer correctly you add sweet moolah to your Super, as you pass Go you collect 2 years.  The game ends when you answer all 12 questions correctly or are 10 years wiser.</p>
<h3>Animation basics</h3>
<p>All animation libraries at their core are a loop that runs as many times as they can over a given time, throughout the loop they calculate the change in position by multiplying the total distance by a progress(between 0 and 1) by an easing function. Easing functions make an animation slow down or speed up throughout the animation.</p>
<p>Here&#8217;s a simple example showing how a position between 0 and 100 could be calculated.</p>
<pre><code lang="javascript">var easing = {
  linear: function (n) {
    return n;
  },
  easeIn: function (n) {
    return Math.pow(n, 1.7);
  },
  easeOut: function (n) {
    return Math.pow(n, .48);
  }
}
var progress = [0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1];
var distance = 100;

for (var i=0, ii = progress.length; i&lt;ii; i++) {
  var position = distance * easing.linear(progress[i])
  console.log(position);
}</code></pre>
<div class="table-wrap">
<table>
<tr>
<th>linear</th>
<td>0</td>
<td>10</td>
<td>20</td>
<td>30</td>
<td>40</td>
<td>50</td>
<td>60</td>
<td>70</td>
<td>80</td>
<td>90</td>
<td>100</td>
</tr>
<tr>
<th>easeIn</th>
<td>0</td>
<td>2</td>
<td>6</td>
<td>13</td>
<td>21</td>
<td>31</td>
<td>42</td>
<td>55</td>
<td>68</td>
<td>84</td>
<td>100</td>
</tr>
<tr>
<th>easeOut</th>
<td>0</td>
<td>33</td>
<td>46</td>
<td>56</td>
<td>64</td>
<td>72</td>
<td>78</td>
<td>84</td>
<td>90</td>
<td>95</td>
<td>100</td>
</tr>
</table>
</div>
<p>Read through the source of <a href="http://berniesumption.com/software/animator/">Animator.js</a> if you want to learn more about it.</p>
<h2>The Car</h2>
<div class="frame" style="margin-bottom: 1em">
  <img src="/journal/wp-content/uploads/2012/03/car.jpg" style="display: block">
</div>
<p>I&#8217;m a big fan of <a href="http://raphaeljs.com/">Raphael.js</a> so at first I tried to use SVG exclusively for the car, animation and path tracking &#8211; and it was working, but testing on the first generation iPad the performance was just too slow to have the desired effect for the game.  I ended up using SVG for the path &#038; Canvas for the rendering.</p>
<h3>Motion paths</h3>
<p><a href="https://developer.mozilla.org/en/DOM/SVGPathElement">SVG paths</a> have the DOM methods getTotalLength() and getPointAtLength(length) which can be used to get specific points along a path.<br />
Those are all we need to move an element along an SVG path with some simple animation timers &#8211; I used jQuery&#8217;s animate function to do this so I didn&#8217;t have to re-invent them. You could pull parts of Animator.js out if you wanted to this yourself.</p>
<h3>Rotation</h3>
<p><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Math/atan2">Math.atan2</a>(point2.x-point1.x, point2.y-point1.y) returns the angle between two points in radians.</p>
<p>When drawing an image on a rotated canvas you need to draw relative to the pivot point of the image &#8211; In the case of the car that&#8217;s the point at the base between the wheels.<br />
ctx.drawImage(image, 0-(width/2), 0-height, width, height);</p>
<h3>Canvas&#8217; transformation matrix</h3>
<p>It took me a little while to understan Canvas&#8217; translation matrix, the <a href="https://developer.mozilla.org/en/Drawing_Graphics_with_Canvas#section_6">Mozilla Canvas docs</a> helped.</p>
<p>If you&#8217;re going to be using rotation in your canvas animations you&#8217;ll need to use save() and restore() to save the current transformation matrix so that you can get back to different points in building the frames.  I think of it as building a frame on the way up using translate, rotate &amp; draw, then tearing it back down again on the way back.</p>
<ul>
<li>clear &#8211; entire canvas
<li>save &#8211; untransformed matrix at (0,0)
<li>translate &#8211; point(x,y)
<li>rotate &#8211; radians
<li>draw &#8211; relative to pivot point
<li>restore &#8211; restore untransformed matrix
</ul>
<h3>The code</h3>
<pre><code lang="javascript">var game = {
  postion: 1,
  steps: 5,
  halfPi: Math.PI/2,
  initPaper: function() {
    var p = game.paper = Raphael('paper', 1022, 762);
    game.path = p.path('M196.5,117.5L906,118c0,0,27.038,5.5,27,29c-0.039,24.331,0,96,0,96s2,28-23,32s-283,2-283,2s-75.86,11.37-76,91c-0.142,81.018,71,88,71,88h52c0,0,31,6,31,40s1,92,1,92s-8,68-74,67s-264,0.011-264,0.011s-24-2.934-24-29.011c0-22.5,22.913-25.153,22.913-25.153L408,601c0,0,75-17,79-94s-82.742-93.03-82.742-93.03L173,414c0,0-76-6-78-78s0-113,0-113l7-28c0,0,0-39,26-62s60-21,60-21L196.5,117.5z').attr({ 'stroke-width': 0 });
    game.pathPoints = [.96, .01, .1, .176, .247, .31, .42, .5, .570, .645, .71, .81, .882, .999];
    game.pathLength = game.path.getTotalLength();
    game.canvas = document.getElementById('canvas');
    game.ctx = dgame.canvas.getContext("2d");

    var img = new Image();
    img.src = 'img/car-work-horse-small.png';
    game.carImage = img;
    game.animateCar(.95, 1, 1000);
  }
  stepCar: function() {
    if (game.steps == 0) return;
    game.steps--;
    var start = game.position;
    game.position++;
    game.animateCar(game.pathPoints[start], game.pathPoints[game.position], 1000, game.stepCar);
  },
  paintCar: function(point) {
    game.x = point.x;
    game.y = point.y;

    var ctx = game.ctx;
    ctx.clearRect(0, 0, game.canvas.width, game.canvas.height);
    ctx.save();
    ctx.translate(game.x, game.y);
    ctx.rotate(game.rotation);
    ctx.drawImage(game.carImage, 0-(game.carWidth/2), 0-game.carHeight, game.carWidth, game.carHeight);
    ctx.restore();
  },
  animateCar: function(start, end, time, complete) {
    var distance = (end-start)*game.pathLength;
    start = start * game.pathLength;
    var ctx = game.ctx;
    var dy, dx, rotation;
    $canvas.animate({ "progress": 1 }, {
      easing: "linear",
      duration: time,
      step: function(a, obj) {
        var point = game.path.getPointAtLength(start + (obj.state * distance));
        dx = point.x-game.x;
        dy = point.y-game.y;
        var rotation = 0-(Math.atan2(dx,dy) - game.halfPi);
        if (dx == 0 &#038;&#038; dy == 0) return; /* same point */
        game.rotation = rotation;
        game.paintCar(point);
      },
      complete: complete || function() {}
    });
  }
}</code></pre>
<h2>The Spinner</h2>
<p>I started out making the spinner rotate with CSS transitions when a click &#038; drag was detected. That was pretty simple to achieve with CSS transitions for a smooth animation with easing.  Sass also helped keep the code nice and simple with math, variables &#038; loops.</p>
<pre><code lang="css">#wheel {
  background: url(../img/spinner.png);
  height: 230px;
  width: 230px;
  position: absolute;
  @include transition(all 1.5s ease-out);
  @for $i from 1 through 6 {
    $rotation = 360deg*3 + $i*60;
    &#038;.spin-#{$i} {
      @include transform(rotate($rotation));
    }
    &#038;.reverse.spin-#{$i} {
      @include transform(rotate(0-$rotation));
    }
  }
}</code></pre>
<pre><code lang="javascript">var touching = false;
var down = function(event) {
  touching = true;
  return false;
}
var move = function(event) {
  if (touching &#038;&#038; !game.spinning) {
    spin();
    touching = false;
  }
}
var up = function(event) {
  touching = false;
}
if (window.Touch) {
  $spinner.bind('touchstart',down);
  $spinner.bind('touchmove',move);
  $spinner.bind('touchend',up);
}
else {
  $spinner.mousedown(down);
  $spinner.mousemove(move);
  $spinner.mouseup(up);
}

function spin() {
  game.spinning = true;
  var number = Math.floor(Math.random()*6)+1;
  $wheel.addClass('spin-'+number);
  game.steps = 6-number || 6;

  setTimeout(function() {
    $wheel.removeClass();
    game.spinning = false;
  }, 3000);
}</code></pre>
<h2>Going both ways</h2>
<div class="frame media">
  <img src="/journal/wp-content/uploads/2012/03/quadrants.jpg">
</div>
<p>Making the spinner go in the reverse was a little more challenging. I needed to capture two points and then figure out which direction it was moving relative to the center of the spinner.</p>
<p>I ended up finding a pretty easy solution by dividing the spinner into into 4 quadrants and simply checking it was moving in one direction. Not perfect, but it works for real world cases.</p>
<p>e.g. If you touched in q1 it&#8217;s spinning in reverse if you move down.</p>
<pre><code lang="javascript">var offset = $wheel.offset();
var pos = null,
quadrant = null,
center = { x: offset.left+115, y: offset.top+115 };

function getPos(event) {
  return {
    x: event.pageX,
    y: event.pageY
  }
}
function getQuadrant() {
  if (pos.x <= center.x &#038;&#038; pos.y <= center.y)
    return 1;
  if (pos.x >= center.x &#038;&#038; pos.y <= center.y)
    return 2;
  if (pos.x >= center.x &#038;&#038; pos.y >= center.y)
    return 3;
  if (pos.x <= center.x &#038;&#038; pos.y >= center.y)
    return 4;
  return null;
}
var down = function(event) {
  event = (window.Touch) ? event.originalEvent.touches[0] : event.originalEvent;
  pos = getPos(event);
  q = getQuadrant();
}
var move = function(event) {
  event = (window.Touch) ? event.originalEvent.touches[0] : event.originalEvent;
  var pos2 = getPos(event);
  if ((q == 1 &#038;&#038; pos2.y > pos.y)
   || (q == 2 &#038;&#038; pos2.x < pos.x)
   || (q == 3 &#038;&#038; pos2.y < pos.y)
   || (q == 4 &#038;&#038; pos2.x > pos.x)) {
    game.spinReverse = true;
  }
  else {
    game.spinReverse = false;
  }
}
var up = function(event) {
  pos = null;
}</code></pre>
<h2>Modals and ornaments</h2>
<div class="frame" style="margin-bottom:1em">
<img src="/journal/wp-content/uploads/2012/03/borders.jpg" style="display: block">
</div>
<p>The dialogs are positioned off screen and transitioned in just by adding a class &#8216;active&#8217;. There&#8217;s really no need for complex javascript frameworks to achieve these sorts of effects anymore &#8211; with CSS3&#8242;s transitions it makes it easy.</p>
<p>I&#8217;ve started using generated content for ornamental elements that aren&#8217;t absolutely necessary for an element to function like the ribbons top &amp; bottom of the dialogs.</p>
<pre><code lang="html">&lt;div id="overlay" class="active"&gt;&lt;/div&gt;
&lt;div id="choose" class="card active"&gt;
&lt;/div&gt;</code></pre>
<pre><code lang="css">#overlay {
  background: rgba(0,0,0,.4);
  position: fixed;
  height: 100%;
  width: 100%;
  opacity: 0;
  @include transition(opacity .3s linear);
  &#038;.active {
    opacity: 1;
  }
}
.card {
  position: absolute;
  top: -800px;
  opacity: 0;
  background: #fff url(../img/texture.jpg);
  @include transition(all .5s ease-in);
  &#038;.active {
    top: 115px;
    opacity: 1;
  }
  &#038;:before {
    content: '';
    height: 11px;
    position: absolute;
    top: -11px;
    left: 0;
    right: 0;
    background: url(../img/ribbon-top.png);
  }
  &#038;:after {
    content: '';
    height: 11px;
    position: absolute;
    bottom: -11px;
    left: 0;
    right: 0;
    background: url(../img/ribbon-bottom.png);
  }
}</code></pre>
<p>These newer CSS properties make the code a lot leaner and easier to change, the way it should be.</p>
<p>And that&#8217;s it! I hope some of the code is useful in your own projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yellowshoe.com.au/journal/svg-motion-paths/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Burger</title>
		<link>http://www.yellowshoe.com.au/journal/burger/</link>
		<comments>http://www.yellowshoe.com.au/journal/burger/#comments</comments>
		<pubDate>Sat, 10 Mar 2012 09:17:18 +0000</pubDate>
		<dc:creator>Mark Brown</dc:creator>
				<category><![CDATA[Food]]></category>

		<guid isPermaLink="false">http://www.yellowshoe.com.au/journal/?p=97</guid>
		<description><![CDATA[In the last three weeks I've been to Misty's, NSHRI, Huxtaburger, Andrews &#038; Grill'd, I love a good burger, but I make an even meaner one.]]></description>
			<content:encoded><![CDATA[<h2>A Hot Burger</h2>
<div class="frame"><img src="/journal/wp-content/uploads/2012/03/burger.jpg" alt="" /></div>
<h2>Ingredients</h2>
<div style="float:left; width: 280px">
<h3>Patties</h3>
<ul>
<li>Beef Mince
<li>Onion
<li>Garlic
<li>Rosemary &amp; Thyme
<li>Breadcrumbs
<li>Worcestershire
<li>Tabasco
<li>Salt &amp; Pepper
</ul>
</div>
<div style="float:left; width: 280px">
<h3>Toppings</h3>
<ul>
<li>Toasted buns
<li>Lettuce
<li>Tomato
<li>Tasty cheese
<li>Bacon
<li>Baxters Tomato Relish
<li>Mayonnaise
<li>Beaver Brand Jalapeno mustard
</ul>
</div>
<p style="clear:left">The Jalapeno mustard / mayo / tomato relish makes this one Tasty Burger.<br />
And, it works out to about $2.50 per burger.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yellowshoe.com.au/journal/burger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Node, a simple server</title>
		<link>http://www.yellowshoe.com.au/journal/node-as-a-simple-server/</link>
		<comments>http://www.yellowshoe.com.au/journal/node-as-a-simple-server/#comments</comments>
		<pubDate>Fri, 02 Mar 2012 06:01:54 +0000</pubDate>
		<dc:creator>Mark Brown</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.yellowshoe.com.au/journal/?p=71</guid>
		<description><![CDATA[Firing up a simple web server is super handy, I've started using node so that I can fire up a server from any directory and view the pages from multiple devices and VM's.]]></description>
			<content:encoded><![CDATA[<p>Most of the things I am working on at the moment are simple front-end prototypes.<br />
Browsing local files via file:///Users/markbrown4/projects/ in different browsers is problematic, you can&#8217;t make ajax requests, some browsers treat local files differently.</p>
<h2>Enter Node</h2>
<p>Node takes a .js file and fires up a web server.<br />
It has a heap of uses, in this case we only need it to do a little &#8211; serve html, css &#038; js.</p>
<h2>Install</h2>
<pre><code style="color: #fff">cd ~/projects/
git clone https://github.com/joyent/node.git
cd node
git checkout v0.6.7
./configure
make
sudo make install</code></pre>
<p>Write a simple web server that serves html, css &#038; js called.. &#8220;front-end-ftw.js&#8221; and put it in the directory of your site / app.</p>
<pre><code lang="javascript">var http = require('http');
var fs = require('fs');
var path = require('path');

http.createServer(function (request, response) {

  console.log('request starting...');

  var filePath = '.' + request.url;
  if (filePath == './')
      filePath = './index.htm';

  var extname = path.extname(filePath);
  var contentType = 'text/html';
  switch (extname) {
    case '.js':
    contentType = 'text/javascript';
    break;
    case '.css':
    contentType = 'text/css';
    break;
  }

  path.exists(filePath, function(exists) {
    if (exists) {
      fs.readFile(filePath, function(error, content) {
        if (error) {
          response.writeHead(500);
          response.end();
        }
        else {
          response.writeHead(200, { 'Content-Type': contentType });
          response.end(content, 'utf-8');
        }
      });
    }
    else {
      response.writeHead(404);
      response.end();
    }
  });
}).listen(8125);

console.log('Server running at http://127.0.0.1:8125/');</code></pre>
<p>http://thecodinghumanist.com/blog/archives/2011/5/6/serving-static-files-from-node-js</p>
<h2>Run it</h2>
<pre><code style="color: #fff">cd ~/projects/my-kick-ass-project/
node front-end-ftw</code></pre>
<h2>Anywhere</h2>
<p>Load http://127.0.0.1:8125/ on an iDevice or test it in your windows vm.</p>
<h2>Content types</h2>
<p>From there you can add any extra content types you want to serve differently, if you want to be able to load images directly in the browser you can add the extensions.<br />
Making an offline web app? Add a cache manifest MIME type.</p>
<pre><code lang="javascript">case '.jpg':
  contentType = 'image';
  break;
case '.png':
  contentType = 'image';
  break;
case '.json':
  contentType = "application/json";
  break;
case '.manifest':
  contentType = 'text/cache-manifest';
  break;</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.yellowshoe.com.au/journal/node-as-a-simple-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
