<?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>Monday By Noon &#187; PNG</title>
	<atom:link href="http://mondaybynoon.com/tag/png/feed/" rel="self" type="application/rss+xml" />
	<link>http://mondaybynoon.com</link>
	<description>A resource for Web designers and developers to read about and discuss their craft.</description>
	<lastBuildDate>Wed, 08 Feb 2012 13:49:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>&#8226; Raising the Bar with Adaptive Templates</title>
		<link>http://mondaybynoon.com/feeder/?FeederAction=clicked&#038;feed=Posts+%28RSS2%29&#038;seed=http%3A%2F%2Fmondaybynoon.com%2F20080428%2Fraising-the-bar-with-adaptive-templates%2F&#038;seed_title=%26%238226%3B+Raising+the+Bar+with+Adaptive+Templates</link>
		<comments>http://mondaybynoon.com/20080428/raising-the-bar-with-adaptive-templates/#comments</comments>
		<pubDate>Mon, 28 Apr 2008 14:03:30 +0000</pubDate>
		<dc:creator>Jonathan Christopher</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Favorites]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Workbench]]></category>
		<category><![CDATA[alpha]]></category>
		<category><![CDATA[constants]]></category>
		<category><![CDATA[Howto]]></category>
		<category><![CDATA[PNG]]></category>
		<category><![CDATA[transparency]]></category>

		<guid isPermaLink="false">http://mondaybynoon.com/?p=140</guid>
		<description><![CDATA[A recent project got me thinking about combining Super-Easy Blendy Backgrounds with CSS constants.<br /><p><a href='http://rss.buysellads.com/click.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=133&c=80107665' target='_blank' rel='nofollow'>
				<img src='http://rss.buysellads.com/img.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=133&c=80107665' border='0' alt='' /></a></p><p><a href='http://buysellads.com/buy/sitedetails/pubkey/2ee344414ac81fbb0f9de6ab08e9831e/zone/1269068' target='_blank'>Advertise here with BSA</a></p>]]></description>
			<content:encoded><![CDATA[<p>I recently completed work on a complete design and development overhaul. To generalize, the project involved a redesign of an online storefront catering to a specific professional. The company I work for was hired to redesign the storefront template as well as overhaul the front end. All the back end development would be taken on in house by the client and we&#8217;d team up to really improve the overall state of things.</p>
<p>I was excited about this project from the start, as was my team. We immediately started throwing ideas back and forth on what we could do to improve the customer experience for this particular storefront. A number of ideas were laid out on the table, some shelved for later phases of the project, and others tightly integrated into the overall design. I&#8217;d like to explain a bit about one feature in particular that ended up garnering quite a bit of the spotlight when the redesign was pushed live.</p>
<p><span id="more-133"></span></p>
<h2>Color adaptation</h2>
<p>I&#8217;d like to say that straight from the beginning the seed for this idea had been planted long ago with the publication of an article to A List Apart titled <a href="http://www.alistapart.com/articles/supereasyblendys">Super-Easy Blendy Backgrounds</a>. Beginning with that article, my eyes had been opened to a new way of thinking when it came to Web design. While there were significant issues with PNGs in IE6, it was obvious to me that alpha transparency will indeed change things on the Web. That article, tied with a great piece written by Jeff Croft, <a href="http://www.digital-web.com/articles/web_standards_creativity_png/">Creative Use of PNG Transparency in Web Design</a>, really got me hooked to the idea of using these unique advantages in upcoming projects.</p>
<p>The advantages of alpha transparency in the PNG image format are great in and of themselves, but for this project I thought we could take things one step further with CSS constants. I recalled reading a number of pieces on this specific subject and taking a liking to the idea. Quite a few designers feel that constants should be a built in feature of CSS, and I agree; it would be useful.</p>
<p>I had never implemented any CSS constant simulations prior to this project, but took comfort in the <a href="http://www.icant.co.uk/articles/cssconstants/">example with extensive documentation</a> by <a href="http://icant.co.uk">Christian Heilmann</a>. His sample was <em>exactly</em> what I was looking for.</p>
<p>I thought it would be completely awesome to tie these two features together; a color-changing template which uses a single color to &#8216;power&#8217; the various shades and hues by taking advantage of alpha transparency by way of PNG.</p>
<p>When it came to the project I&#8217;d be working on, my company was merely in the discussion and planning phase with the client, I wasn&#8217;t 100% sure I&#8217;d be able to implement a feature such as this. I thought a bit about it and we decided it best to simply offer our proposal without specific mention of this feature. After successful test implementations, we&#8217;d mention to the client that we will be providing this additional functionality should there be interest.</p>
<p>I teamed with a single designer through the life of this project and he made the conscious effort to use only white and black in the design, but in transparent levels more often than not. He was able to use a solid color bottom-most layer in Photoshop to mimic how things would work in a Web browser. Our tests were quite successful and the idea was presented to the client. They fell in love with it and we began work. As you can imagine, cross-browser support was at times an issue, but I&#8217;ve got to say that overall the feature implementation was a very successful. Our client was able to offer an extremely versatile design to their clients, allowing them to customize the colors used throughout the redesign.</p>
<h2>Extreme darks or lights</h2>
<p>It became apparent almost immediately that we would need three separate variations of the same theme to account for variable choices on the part of our client&#8217;s clients. If a solid black background color were chosen, we&#8217;d need to make sure that all the design elements are equally visible throughout the design. The same applies for a solid white background color. At the end of the day, I ended up cutting three &#8216;sets&#8217; of images: one for very dark background colors, one for very light background colors, and a third for mid-range colors.</p>
<p>The inclusion of this hurdle alone required some modifications to <a href="http://www.icant.co.uk/articles/cssconstants/">Christian Heilmann&#8217;s CSS constant simulation example</a>; I had to account for the three ranges of color. The W3C published an <a href="http://www.w3.org/TR/AERT#color-contrast">algorithm to measure color visibility</a> which I included in the CSS parser originally written by Christian Heilmann. I compared the color chosen as the background color to both black and white and measured the difference between. With some arbitrary testing, I included a tolerance variable which the client could adjust down the line if they&#8217;d like. The result came to be:</p>
<pre class="sh_php"><code>&lt;?php
/*
	cssconst.php
	written by Chris Heilmann (http://icant.co.uk)
	allows constants to be used in the css
	file sent in the get variable c
	constant format:
	$foo='bar';

	Modification by Jonathan Christopher () to
	include a function to measure the color contrast of a variable set
	in the CSS. That value then sets another variable for use with image
	filenames.
*/

$background 	= '#8094b2';
$mainText 	= '#fff';
$altText 	= '#000';
$tolerance 	= 100;

$white = (hexrgb('ffffff'));
$black = (hexrgb('000000'));

function hexrgb($hexstr) {
    $int = hexdec($hexstr);
    return array("red" =&gt; 0xFF &amp; ($int &gt;&gt; 0x10), "green" =&gt; 0xFF &amp; ($int &gt;&gt; 0x8), "blue" =&gt; 0xFF &amp; $int);
}

header('content-type:text/css');
//header("Expires: ".gmdate("D, d M Y H:i:s", (time()+900)) . " GMT");
$c=$_GET['c'];
$css=load($c);
if($css=='') { die('File not Found, sorry!'); }
preg_match_all("/\\$(\w+).*=.*\'(.*)\'/",$css,$constants);

// ---------------------------------
// determine color difference
// ---------------------------------

$targetHex = $background;

if(strlen($targetHex)==4) {
	$hexArray = str_split($targetHex);
	$targetHex  = $hexArray[1];
	$targetHex .= $hexArray[1];
	$targetHex .= $hexArray[2];
	$targetHex .= $hexArray[2];
	$targetHex .= $hexArray[3];
	$targetHex .= $hexArray[3];
} elseif(strlen($targetHex)!=7) {
	$targetHex = '#8094b2';						// worse case: use default
}

$color = (hexrgb($targetHex));

// Determine how different the color is from white
$whiteDiff  = max($color["red"],$white["red"])-min($color["red"],$white["red"]);
$whiteDiff += max($color["green"],$white["green"])-min($color["green"],$white["green"]);
$whiteDiff += max($color["blue"],$white["blue"])-min($color["blue"],$white["blue"]);

// Determine how different the color is from black
$blackDiff  = max($color["red"],$black["red"])-min($color["red"],$black["red"]);
$blackDiff += max($color["green"],$black["green"])-min($color["green"],$black["green"]);
$blackDiff += max($color["blue"],$black["blue"])-min($color["blue"],$black["blue"]);

if(!isset($image_suffix)){
if($whiteDiff&lt;$tolerance) {
	$image_suffix 	= '-light';
} elseif($blackDiff&lt;$tolerance) {
	$image_suffix 	= '-dark';
	} else {
	$image_suffix 	= '';
}}

// ---------------------------------
// apply background
// ---------------------------------
$css=preg_replace('/\\$background/',$background,$css);

// ---------------------------------
// apply suffix
// ---------------------------------
$css=preg_replace('/\\$image_suffix/',$image_suffix,$css);

// ---------------------------------
// apply mainText
// ---------------------------------
$css=preg_replace('/\\$mainText/',$mainText,$css);

// ---------------------------------
// apply altText
// ---------------------------------
$css=preg_replace('/\\$altText/',$altText,$css);

// ---------------------------------
// finish it up and echo
// ---------------------------------
$css=preg_replace("/\\#.*=.*?;\s+/s",'',$css);
echo $css;

/*
	Function load($file)
	reads the content of the file that you send and returns it
*/
function load($filelocation)
{
	if (file_exists($filelocation))
	{
		$newfile = fopen($filelocation,"r");
		$file_content = fread($newfile, filesize($filelocation));
		fclose($newfile);
		return $file_content;
	}
}
?&gt;</code></pre>
<p>If you&#8217;ll note, there are four variables to consider when using the above script. These variables were stored in a database and saved as a session variable server side. The <code>$background</code> variable controlled the overall color scheme used in the design by using it as the background color for the <code>body</code> as well as a few other strategic places where it was needed. <code>$mainText</code> was the primary text color used in the design, <code>$altText</code> was used in those certain circumstances where another color spiced things up a bit, and the <code>$tolerance</code> variable controlled how close a color had to be to either white or black before it was decided which background images were to be used to ensure proper contrast.</p>
<p>To implement the variables in the CSS, you simply add them as PHP variables:</p>
<pre class="sh_css"><code>body { background-color:$background; color:$mainText; }</code></pre>
<p>The way I was able to distinguish which &#8216;set&#8217; of images to use was partially twofold. My first step was to name each image accordingly. Much of the time, the same image itself could be, but there were other times were a black gradient on an image needed to me changed to a white gradient when a very dark background color was chosen. To get around the issue, I added a suffix to the filename of applicable images. For example, bg-body.png would have two additional images; bg-body-light.png and bg-body-dark.png. I was able to take advantage of this naming structure in both the CSS as well as the parser by referencing the images as something like:</p>
<pre class="sh_css"><code>div#example { background:$background url(../images/bg-body$image_suffix.png) no-repeat; }
</pre>
<p></code></p>
<p>All of my bases were covered. If the background was too dark, one suffix would be added in the parser, another suffix added if the color were too light, and the suffix would simply be empty if the color was middle of the line.</p>
<h3>I hope it's useful to someone else</h3>
<p>The inclusion of this feature turned out to be extremely useful in this case, and I hope others are able to take advantage of the idea. I'm sure there are endless ways to improve this specific implementation, so certainly feel free to offer both your thoughts and critiques.</p>
<br /><p><a href='http://rss.buysellads.com/click.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=133&c=1783705102' target='_blank' rel='nofollow'>
				<img src='http://rss.buysellads.com/img.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=133&c=1783705102' border='0' alt='' /></a></p><p><a href='http://buysellads.com/buy/sitedetails/pubkey/2ee344414ac81fbb0f9de6ab08e9831e/zone/1269068' target='_blank'>Advertise here with BSA</a></p>]]></content:encoded>
			<wfw:commentRss>http://mondaybynoon.com/20080428/raising-the-bar-with-adaptive-templates/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>&#8226; Working with Background PNGs and Internet Explorer 6</title>
		<link>http://mondaybynoon.com/feeder/?FeederAction=clicked&#038;feed=Posts+%28RSS2%29&#038;seed=http%3A%2F%2Fmondaybynoon.com%2F20080211%2Fworking-with-background-pngs-and-internet-explorer-6%2F&#038;seed_title=%26%238226%3B+Working+with+Background+PNGs+and+Internet+Explorer+6</link>
		<comments>http://mondaybynoon.com/20080211/working-with-background-pngs-and-internet-explorer-6/#comments</comments>
		<pubDate>Mon, 11 Feb 2008 14:20:12 +0000</pubDate>
		<dc:creator>Jonathan Christopher</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[GIF]]></category>
		<category><![CDATA[IE6]]></category>
		<category><![CDATA[PNG]]></category>

		<guid isPermaLink="false">http://mondaybynoon.com/2008/02/11/working-with-pngs-and-internet-explorer-6/</guid>
		<description><![CDATA[Using PNG images as backgrounds can be very helpful and useful, but there are some things to keep in mind when working with Internet Explorer 6.<br /><p><a href='http://rss.buysellads.com/click.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=121&c=1808738745' target='_blank' rel='nofollow'>
				<img src='http://rss.buysellads.com/img.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=121&c=1808738745' border='0' alt='' /></a></p><p><a href='http://buysellads.com/buy/sitedetails/pubkey/2ee344414ac81fbb0f9de6ab08e9831e/zone/1269068' target='_blank'>Advertise here with BSA</a></p>]]></description>
			<content:encoded><![CDATA[<p>PNGs are a fantastic way to extend certain limitations of other image formats. Alpha transparency becomes a major asset in many circumstances, and will continue to be further adapted as time goes on. There was an article published to <a href="http://www.alistapart.com">A List Apart</a> quite some time ago which outlined a possibility of using PNG images as backgrounds to help alleviate some tediousness while creating background images.</p>
<p>This article, like many from A List Apart, really stuck in my mind as something quite innovative and useful; I just needed the right time to apply the technique. <a href="http://www.alistapart.com/articles/supereasyblendys">Super-Easy Blendy Backgrounds</a> was published November 13, 2006 and I hadn&#8217;t come across a project to <em>really</em> make use of the technique until a few months ago. As the project was just coming together, Super-Easy Blendy Backgrounds instantly came to mind as a major time-saver for this particular client project.</p>
<p>Instantly, I was terrified of making things work in <abbr title="Internet Explorer 6">IE6</abbr>. While you can use the <a href="http://msdn2.microsoft.com/en-us/library/ms532969(VS.85).aspx">AlphaImageLoader Filter</a>, I know there would be some major issues as the project carried into development. There were.</p>
<h2>Things to keep in mind with PNG background images and IE6</h2>
<p>While the article published to A List Apart was extremely comprehensive and detailed, I went about things a bit differently. <a href="http://www.alistapart.com/articles/supereasyblendys">Super-Easy Blendy Backgrounds</a> used inline images to achieve the desired effect, and I wanted to use background images. The effect was masterful everywhere except IE6, which is where the work began.</p>
<p>There were two major problems I encountered very quickly when working with PNG background images and IE6. The first problem I discovered was <strong>huge</strong>. When using AlphaImageLoader, links will not behave as expected in IE6. You&#8217;re stuck with a link that does absolutely nothing. I ran across multiple articles regarding this issue, many with varying circumstances and solutions for the bug. <a href="http://www.hrunting.org/csstests/iealpha.html">The solution that worked</a> indicated the bug can be alleviated by ensuring the element using AlphaImageLoader has <em>no <code>position</code> set</em> and the anchor within said element <em>does have a <code>position</code></em>. There were other solutions offered elsewhere, some indicating that the bug is triggered by the actual dimensions of the image you&#8217;re using as a background, but that didn&#8217;t help me as the images I were using were quite unique. It&#8217;s important to be aware that this <strong>may not always solve your problem</strong>. There may be times where you&#8217;ll simply need to find an alternative solution to this major problem with IE6.</p>
<p>The second major problem I came across was trying to tile background images for elements. Using AlphaImageLoader this simply isn&#8217;t possible. You&#8217;re forced to either crop or scale the background image. Using <code>background-position</code> or <code>background-repeat</code> is not an option. This forced me to use larger images in certain places, as well as use GIFs in other areas. You are able to set the <code>sizingMethod</code> to <code>crop</code>, but that may not be entirely useful.</p>
<h3>How did things work out?</h3>
<p>I&#8217;m quite pleased with how this project is turning out. Using PNGs effectively throughout the design will help this particular client adapt a single design by creating many color combinations by changing a couple variables on their back end. While the IE6 version of the design isn&#8217;t nearly as attractive as when it&#8217;s rendered using a fully capable browser, it degrades quite nicely and many of the features remain in tact.</p>
<p>The important thing to keep in mind when using techniques not fully supported cross-browser is to thoroughly test; <strong>especially for client work</strong>. How have your experiences been with using PNG?</p>
<br /><p><a href='http://rss.buysellads.com/click.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=121&c=1394242049' target='_blank' rel='nofollow'>
				<img src='http://rss.buysellads.com/img.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=121&c=1394242049' border='0' alt='' /></a></p><p><a href='http://buysellads.com/buy/sitedetails/pubkey/2ee344414ac81fbb0f9de6ab08e9831e/zone/1269068' target='_blank'>Advertise here with BSA</a></p>]]></content:encoded>
			<wfw:commentRss>http://mondaybynoon.com/20080211/working-with-background-pngs-and-internet-explorer-6/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Database Caching 1/56 queries in 0.069 seconds using apc
Object Caching 621/694 objects using apc

Served from: www.mondaybynoon.com @ 2012-02-09 05:58:43 -->
