<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'fade a hex color' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'fade a hex color' posted on the 'PHP' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sat, 18 May 2013 20:59:51 -0700</pubDate>
    <lastBuildDate>Sat, 18 May 2013 20:59:51 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>fade a hex color</title>
      <link>http://www.programmersheaven.com/mb/phpstuff/166720/166720/fade-a-hex-color/</link>
      <description>does anybody know how to fade a hex color by a certain amount? e.g. I need a PHP function like fade('#FFAEFF', -10 ).  I code use the rbg(0,0,0) but that only works in IE.  I want to fade my tables.&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;&lt;br /&gt;
&lt;a href="http://owensoft.20m.com"&gt;http://owensoft.20m.com&lt;/a&gt;&lt;br /&gt;
check out my current projects: &lt;a href="http://www.owensoft.net"&gt;http://www.owensoft.net&lt;/a&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/phpstuff/166720/166720/fade-a-hex-color/</guid>
      <pubDate>Wed, 22 Jan 2003 09:03:23 -0700</pubDate>
      <category>PHP</category>
    </item>
    <item>
      <title>I know that! that not the problem</title>
      <link>http://www.programmersheaven.com/mb/phpstuff/166720/166770/i-know-that-that-not-the-problem/#166770</link>
      <description>Hint: increase all values (red AND blue AND green) with the same amount, which will give you a fade effect.&lt;br /&gt;
For example:&lt;br /&gt;
 #989898 - Original: gray&lt;br /&gt;
 #A9A9A9 - Increased all by hex 11&lt;br /&gt;
 #EDEDED - Increased all by hex 44&lt;br /&gt;
 #FFFFFF - Finally, they become white&lt;br /&gt;
&lt;br /&gt;
Or decrease them if you want to fade to black.&lt;br /&gt;
&lt;br /&gt;
: does anybody know how to fade a hex color by a certain amount? e.g. I need a PHP function like fade('#FFAEFF', -10 ).  I code use the rbg(0,0,0) but that only works in IE.  I want to fade my tables.&lt;br /&gt;
: &lt;br /&gt;
: &lt;hr /&gt;&lt;br /&gt;
: &lt;a href="http://owensoft.20m.com"&gt;http://owensoft.20m.com&lt;/a&gt;&lt;br /&gt;
: check out my current projects: &lt;a href="http://www.owensoft.net"&gt;http://www.owensoft.net&lt;/a&gt;&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/phpstuff/166720/166770/i-know-that-that-not-the-problem/#166770</guid>
      <pubDate>Wed, 22 Jan 2003 13:16:11 -0700</pubDate>
      <category>PHP</category>
    </item>
    <item>
      <title>I know that! that not the problem</title>
      <link>http://www.programmersheaven.com/mb/phpstuff/166720/166784/i-know-that-that-not-the-problem/#166784</link>
      <description>&lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by owen1 at  2003-1-22 13:49:54&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
: Hint: increase all values (red AND blue AND green) with the same &lt;br /&gt;
&lt;br /&gt;
:x I know that. that's not the problem. the problem is increasing the hex value.  You know like 1 + 1 = 2 but not with numbers with hex values.  I need to know or a function that adds (or subtracts) #0000ff from #0AAAEE.  Get what I am saying?&lt;br /&gt;
&lt;hr /&gt;&lt;br /&gt;
&lt;a href="http://owensoft.20m.com"&gt;http://owensoft.20m.com&lt;/a&gt;&lt;br /&gt;
check out my current projects: &lt;a href="http://www.owensoft.net"&gt;http://www.owensoft.net&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/phpstuff/166720/166784/i-know-that-that-not-the-problem/#166784</guid>
      <pubDate>Wed, 22 Jan 2003 13:47:31 -0700</pubDate>
      <category>PHP</category>
    </item>
    <item>
      <title>Re: I know that! that not the problem</title>
      <link>http://www.programmersheaven.com/mb/phpstuff/166720/167086/re-i-know-that-that-not-the-problem/#167086</link>
      <description>i wanted to do the same thing on my site at awulf.inversiondesigns.com for my calendar.&lt;br /&gt;
&lt;br /&gt;
here's the code i used.&lt;br /&gt;
you input two hex colors, and the degree to which you want to fade between the two. here ya go...&lt;br /&gt;
&lt;br /&gt;
an example call to the function is&lt;br /&gt;
$new_color = figureColor("#000000", "#FFFFFF", 5); will return a gray of some sort. play around with the value you send $count. i can't remember what its bounds are. but this code should do the trick.&lt;br /&gt;
&lt;br /&gt;
--------------------&lt;br /&gt;
&lt;br /&gt;
function figureColor($dark, $light, $count){&lt;br /&gt;
// $dark and $light come in format "#FFFFFF" or something.&lt;br /&gt;
// they have the # with 'em&lt;br /&gt;
	$dark = substr($dark, 1, 6);&lt;br /&gt;
	$light = substr($light, 1, 6);&lt;br /&gt;
&lt;br /&gt;
	$offset = array();&lt;br /&gt;
	for($i = 0; $i &amp;lt;6; $i+=2){&lt;br /&gt;
		$offset[] = getOffset(substr($dark, $i, 2), substr($light, $i, 2), $count);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
  //rebuild the new color.&lt;br /&gt;
	$newColor = implode("", $offset);&lt;br /&gt;
	$newColor = "#" . $newColor;&lt;br /&gt;
&lt;br /&gt;
	return $newColor;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function getOffSet($dark_in, $light_in, $count){&lt;br /&gt;
  // $dark_in and $light_in are only one color of the rgb&lt;br /&gt;
  // example for a color #FFCC99, the inputs would be sent in&lt;br /&gt;
  //   as either a FF, CC, or 99.&lt;br /&gt;
  // returns the faded portion of either the color input&lt;br /&gt;
	$lighterAmount = 17;&lt;br /&gt;
&lt;br /&gt;
	$dark = array();&lt;br /&gt;
	$dark[] = hexToInt(substr($dark_in,0,1));&lt;br /&gt;
	$dark[] = hexToInt(substr($dark_in,1,1));&lt;br /&gt;
&lt;br /&gt;
	$light = array();&lt;br /&gt;
	$light[] = hexToInt(substr($light_in,0,1));&lt;br /&gt;
	$light[] = hexToInt(substr($light_in,1,1));&lt;br /&gt;
&lt;br /&gt;
	$dark[0] *= 16;&lt;br /&gt;
	$light[0] *= 16;&lt;br /&gt;
&lt;br /&gt;
	$dark = $dark[0] + $dark[1];&lt;br /&gt;
	$light = $light[0] + $light[1];&lt;br /&gt;
&lt;br /&gt;
	$new = $light - $dark - $lighterAmount;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	$new = $new * $count/3;&lt;br /&gt;
	$new = intval($new);&lt;br /&gt;
&lt;br /&gt;
	if($new &amp;lt; 0){&lt;br /&gt;
		$new = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if($new &amp;gt; 255){&lt;br /&gt;
		$new = 255;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	$new = $light - $new;&lt;br /&gt;
&lt;br /&gt;
	$new = intToHex($new);&lt;br /&gt;
&lt;br /&gt;
	return $new;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function hexToInt($ret){&lt;br /&gt;
	if(strtoupper($ret) == "F"){&lt;br /&gt;
		$ret = 15;&lt;br /&gt;
	}else&lt;br /&gt;
	if(strtoupper($ret) == "E"){&lt;br /&gt;
		$ret = 14;&lt;br /&gt;
	}else&lt;br /&gt;
	if(strtoupper($ret) == "D"){&lt;br /&gt;
		$ret = 13;&lt;br /&gt;
	}else&lt;br /&gt;
	if(strtoupper($ret) == "C"){&lt;br /&gt;
		$ret = 12;&lt;br /&gt;
	}else&lt;br /&gt;
	if(strtoupper($ret) == "B"){&lt;br /&gt;
		$ret = 11;&lt;br /&gt;
	}else&lt;br /&gt;
	if(strtoupper($ret) == "A"){&lt;br /&gt;
		$ret = 10;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	return $ret;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function intToHex($ret){&lt;br /&gt;
&lt;br /&gt;
	$hex = array();&lt;br /&gt;
	$one = $ret % 16;&lt;br /&gt;
	$ret -= $one;&lt;br /&gt;
	$hex[] = $ret / 16;&lt;br /&gt;
	$hex[] = $one;&lt;br /&gt;
&lt;br /&gt;
	if($hex[0] &amp;lt; 0){&lt;br /&gt;
		$hex[0] = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if($hex[1] &amp;lt; 0){&lt;br /&gt;
		$hex[1] = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	for($i = 0; $i &amp;lt; 2; $i++){&lt;br /&gt;
		if($hex[$i] == 15){&lt;br /&gt;
			$hex[$i] = "F";&lt;br /&gt;
		}else&lt;br /&gt;
		if($hex[$i] == 14){&lt;br /&gt;
			$hex[$i] = "E";&lt;br /&gt;
		}else&lt;br /&gt;
		if($hex[$i] == 13){&lt;br /&gt;
			$hex[$i] = "D";&lt;br /&gt;
		}else&lt;br /&gt;
		if($hex[$i] == 12){&lt;br /&gt;
			$hex[$i] = "C";&lt;br /&gt;
		}else&lt;br /&gt;
		if($hex[$i] == 11){&lt;br /&gt;
			$hex[$i] = "B";&lt;br /&gt;
		}else&lt;br /&gt;
		if($hex[$i] == 10){&lt;br /&gt;
			$hex[$i] = "A";&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	$hex = implode("", $hex);&lt;br /&gt;
&lt;br /&gt;
	return $hex;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: &lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by owen1 at  2003-1-22 13:49:54&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
: : Hint: increase all values (red AND blue AND green) with the same &lt;br /&gt;
: &lt;br /&gt;
: :x I know that. that's not the problem. the problem is increasing the hex value.  You know like 1 + 1 = 2 but not with numbers with hex values.  I need to know or a function that adds (or subtracts) #0000ff from #0AAAEE.  Get what I am saying?&lt;br /&gt;
: &lt;hr /&gt;&lt;br /&gt;
: &lt;a href="http://owensoft.20m.com"&gt;http://owensoft.20m.com&lt;/a&gt;&lt;br /&gt;
: check out my current projects: &lt;a href="http://www.owensoft.net"&gt;http://www.owensoft.net&lt;/a&gt;&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/phpstuff/166720/167086/re-i-know-that-that-not-the-problem/#167086</guid>
      <pubDate>Thu, 23 Jan 2003 22:42:36 -0700</pubDate>
      <category>PHP</category>
    </item>
    <item>
      <title>Re: I know that! that not the problem</title>
      <link>http://www.programmersheaven.com/mb/phpstuff/166720/167188/re-i-know-that-that-not-the-problem/#167188</link>
      <description>thanx, for you help &lt;br /&gt;
it's a bit long but I'll figure it out&lt;br /&gt;
&lt;hr /&gt;&lt;br /&gt;
&lt;a href="http://owensoft.20m.com"&gt;http://owensoft.20m.com&lt;/a&gt;&lt;br /&gt;
check out my current projects: &lt;a href="http://www.owensoft.net"&gt;http://www.owensoft.net&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/phpstuff/166720/167188/re-i-know-that-that-not-the-problem/#167188</guid>
      <pubDate>Fri, 24 Jan 2003 08:50:02 -0700</pubDate>
      <category>PHP</category>
    </item>
  </channel>
</rss>