<?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>Farrworks &#187; Corners</title>
	<atom:link href="http://farrworks.com/tag/corners/feed/" rel="self" type="application/rss+xml" />
	<link>http://farrworks.com</link>
	<description>Technology, Work, Life, Play, and everything else in between the ears of an Ian...</description>
	<lastBuildDate>Fri, 26 Feb 2010 22:17:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Javascript Rounded Corners and JQuery</title>
		<link>http://farrworks.com/2008/10/javascript-rounded-corners-jquery-cakephp/</link>
		<comments>http://farrworks.com/2008/10/javascript-rounded-corners-jquery-cakephp/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 04:15:12 +0000</pubDate>
		<dc:creator>Ian Farr</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Corners]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[WebDev]]></category>

		<guid isPermaLink="false">http://farrworks.com/?p=85</guid>
		<description><![CDATA[In one of my projects I needed some nice rounded corners, but I needed to have the flexibility to style them, and change colors easily, and quickly as needed. I usually used Nifty Corners, and have had good success with it, but this time around, I wanted to see if I could do it all [...]]]></description>
			<content:encoded><![CDATA[<p>In one of my projects I needed some nice rounded corners, but I needed to have the flexibility to style them, and change colors easily, and quickly as needed. I usually used <a href="http://www.html.it/articoli/niftycube/index.html">Nifty Corners</a>, and have had good success with it, but this time around, I wanted to see if I could do it all in jquery.<br />
<span id="more-85"></span><br />
First, some background on why I used Nifty in the past. I know that the corners that Nifty produces are not the best quality, but they are passable. Also, the script runs fairly quickly, and can round many corners on a page pretty fast &#8211; fast enough to use on a production site and not have it bog down. Lastly, it has some really cool options that only a few others have, and in some cases nobody has. Stuff like:</p>
<ul>
<li>rounding different types of elements &#8211; not just div&#8217;s, but p&#8217;s, h#&#8217;s, and lists (ordered and unordered) can be specified and rounded.</li>
<li>transparency support</li>
<li>fixed-height option (if you need a fixed height defined in css)</li>
<li>same-height option. this is by far my favorite. you can use this for layouts, or many other things. I once had to make 12 divs the same size &#8211; no matter what data was in them. The layout was a 2 column layout, and so the 12 divs were in two columns of 6 each. If one div needed enough room for 15 lines, all the rest of the divs needed to grow to match the size &#8211; so everything would still look even  &#8211; that is one div should never be smaller or bigger then the rest of them &#8211; all had to be the same size &#8211; no matter what. This can be a litle tricky, but a no-brainer with the same-height option, and you get rounded corners for free too &#8211; bonus!</li>
</ul>
<p>For these reasons, and another being that it&#8217;s soo easy to use, I am a fan of Nifty. Although I knew that I could use it, and that it plays fairly nice with jquery on it&#8217;s own, I wanted to see if I could stay within jquery realm&#8230;</p>
<p>I quickly found some basic corner plugins for jquery to round my corners, but most of them were not pretty at all, no anti-aliasing, and so the corners looked pretty jagged. Not very attractive at all. I know that Nifty Corners isn&#8217;t the best as far as anti-aliasing goes, but these were much worse then the results that one can get with Nifty.</p>
<p>I searched around some more, and pretty much found what I was looking for with the <a href="http://blue-anvil.com/archives/anti-aliased-rounded-corners-with-jquery">&#8220;JQuery Corner&#8221;</a> plugin. The JQuery Corner plugin is more or less a port of the curvy corners script to jquery, so you can use the jquery syntax to locate sections on the page and round them easily. It&#8217;s a simpe as:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#rounded'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">corner</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>I mean, it can&#8217;t get much easier then this can it! Just use jquery to select the elements you want, and round them. You can also pass the normal curvey corners parameters to control how large the corners should be, which corners should be rounded, etc..</p>
<p>This was fine and all, but I continued my quest to see what other options there were. There was the interesting <a href="http://dev.jquery.com/~paul/plugins/nifty/example.html">Nifty Corners port to jquery</a> which also caught my attention.</p>
<p>At first I thought that this was it&#8230;all the benefits of Nifty right in jquery &#8211; could it be true? Although on it&#8217;s own it did work, I just wasn&#8217;t able to get it working on IE through cakephp for some reason. Other browsers worked fine, but on IE7 &#8211; nothing. No errors, and worst of all, no round corners. I tried different things, but in the end simply gave up. It&#8217;s too bad also, as I really liked this idea.</p>
<p>Well &#8211; all was not lost, as I knew that I could just use Nifty as is, inside jquery&#8217;s $(document).ready() statement. just load up your jquery javascript file, and load Nifty&#8217;s javascript right after. After that, all that is needed is:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; Nifty<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#rounded'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'big'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>Basically, just use Nifty as described in it&#8217;s home page. We are just using jquery&#8217;s document.ready statement to control when Nifty does it&#8217;s job.</p>
<p>Since I now had two options that were interesting, and one was outside of the jquery world &#8211; I thought to myself &#8220;hey, since I am already outside the jquery world &#8211; I might as well try the Cadillac of rounded corners..&#8221;. I have known about, and used <a href="http://www.ruzee.com/blog/shadedborder/">Ruzee&#8217;s corners</a>, but didn&#8217;t like the fact that it&#8217;s heavy. The new one seems a little faster, and although it produces absolutely beautiful corners, it still is heavy and a little slow when trying to round lots of corners on a page. As a simple test, just load up the demo page, and try to scroll around and watch your CPU. Just resize the window, and scroll around and listen to your CPU fan start to kick in.</p>
<p>It also plays nice with jquery &#8211; all that is needed it to simply load up the shadedborder.js file after you load up jquery, and then do something like:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> border <span style="color: #339933;">=</span> RUZEE.<span style="color: #660066;">ShadedBorder</span>.<span style="color: #660066;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> corner<span style="color: #339933;">:</span>8<span style="color: #339933;">,</span> shadow<span style="color: #339933;">:</span>16<span style="color: #339933;">,</span> &nbsp;border<span style="color: #339933;">:</span>2 <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; border.<span style="color: #660066;">render</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rounded'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>Again, we are using jquery&#8217;s document.ready statement to control when shadedborder will start doing it&#8217;s magic.</p>
<p>All 3 options are viable in my opinion. Ruzee border is by far the prettiest &#8211; with it&#8217;s drop shadow ability and all, but it&#8217;s also the heaviest by far. If you do use it, use it sparingly. The JQuery Corner plugin is pretty good also, and lighter then Ruzee&#8217;s corners. It also produces nice anti-aliased clean corners, and works in all browsers that I threw at it. And good ol&#8217; Nifty corners with it&#8217;s &#8216;passable&#8217; corners but very usefull features is the lightest and fastest of the bunch. If you have many corners to round in a single page, Nifty is the way to go. You will sacrifice a bit of the look for speed and usability.</p>
<p>As far as script sizes go, it is very surprising that Ruzee and Nifty are tied for 1st place &#8211; with each weighing in at 9KB. Pretty impressive. JQuery Corner is double in size (the minified version) weighing in at 19KB. Although you can use the packed version if you want at 13KB. Still larger then Ruzee or Nifty though.</p>
<p>The one thing that I have left to test is seeing how heavy/fast Ruzee&#8217;s corners are if I get rid of drop shadow (.., shadow:0, &#8230;). At 9KB, it&#8217;s a very impressive library, and produces beautiful results&#8230;.but maybe that will be a discussion for another day.</p>
<p>What is perhaps the most interesting, is that you can use all 3 of them together with ease. So you can use Nifty for the &#8220;I need lots of corners all over the place and so need speed&#8221; things, and then use Ruzee or JQuery Corner when you need larger, prettier corners, but only on an single (or a few) element(s). </p>
<p>For my uses, I think it will be a combination of Nifty and Ruzee, as both are smaller then JQuery Corner&#8217;s, and Ruzee produces &#8220;photoshop quality&#8221; corner effects that are really great.</p>
]]></content:encoded>
			<wfw:commentRss>http://farrworks.com/2008/10/javascript-rounded-corners-jquery-cakephp/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
